mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
bpo-29990: Fix range checking in GB18030 decoder (#1495)
When decoding a 4-byte GB18030 sequence, the first and third byte cannot exceed 0xFE.
This commit is contained in:
parent
fa5abac1e6
commit
9da408d15b
3 changed files with 11 additions and 1 deletions
|
@ -48,6 +48,12 @@ class Test_GB18030(multibytecodec_support.TestBase, unittest.TestCase):
|
|||
(b"abc\x84\x32\x80\x80def", "replace", 'abc\ufffd2\ufffd\ufffddef'),
|
||||
(b"abc\x81\x30\x81\x30def", "strict", 'abc\x80def'),
|
||||
(b"abc\x86\x30\x81\x30def", "replace", 'abc\ufffd0\ufffd0def'),
|
||||
# issue29990
|
||||
(b"\xff\x30\x81\x30", "strict", None),
|
||||
(b"\x81\x30\xff\x30", "strict", None),
|
||||
(b"abc\x81\x39\xff\x39\xc1\xc4", "replace", "abc\ufffd\x39\ufffd\x39\u804a"),
|
||||
(b"abc\xab\x36\xff\x30def", "replace", 'abc\ufffd\x36\ufffd\x30def'),
|
||||
(b"abc\xbf\x38\xff\x32\xc1\xc4", "ignore", "abc\x38\x32\u804a"),
|
||||
)
|
||||
has_iso10646 = True
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue