diff options
author | Bob Ippolito <bob@redivi.com> | 2022-04-21 16:10:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-21 16:10:31 -0700 |
commit | d8cee7b2c5696a76e2d0316188b100eea4264354 (patch) | |
tree | da1c6e0f865f359739c471d31baf16feba6bec32 | |
parent | 02221b19672b1b35188080435c7360cd2d6af6fb (diff) | |
parent | 4eee7207da04f974b3b79caf29cacb6f709ad464 (diff) | |
download | simplejson-d8cee7b2c5696a76e2d0316188b100eea4264354.tar.gz |
Merge pull request #298 from ks888/fix-value-error
Check the unicode code point range before unichr() is called
-rw-r--r-- | simplejson/decoder.py | 2 | ||||
-rw-r--r-- | simplejson/tests/test_scanstring.py | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/simplejson/decoder.py b/simplejson/decoder.py index 7f0b056..1a8f772 100644 --- a/simplejson/decoder.py +++ b/simplejson/decoder.py @@ -109,6 +109,8 @@ def py_scanstring(s, end, encoding=None, strict=True, uni = int(esc, 16) except ValueError: raise JSONDecodeError(msg, s, end - 1) + if uni < 0 or uni > _maxunicode: + raise JSONDecodeError(msg, s, end - 1) end += 5 # Check for surrogate pair on UCS-4 systems # Note that this will join high/low surrogate pairs diff --git a/simplejson/tests/test_scanstring.py b/simplejson/tests/test_scanstring.py index d5de180..c6c53b8 100644 --- a/simplejson/tests/test_scanstring.py +++ b/simplejson/tests/test_scanstring.py @@ -132,6 +132,8 @@ class TestScanString(TestCase): self.assertRaises(ValueError, scanstring, '\\ud834\\x0123"', 0, None, True) + self.assertRaises(json.JSONDecodeError, scanstring, "\\u-123", 0, None, True) + def test_issue3623(self): self.assertRaises(ValueError, json.decoder.scanstring, "xxx", 1, "xxx") |