Message291153
This issue is split from issue24117, that issue became a soup of small issues, so I'm going to close it.
For 4-byte GB18030 sequence, the legal range is:
0x81-0xFE for the 1st byte
0x30-0x39 for the 2nd byte
0x81-0xFE for the 3rd byte
0x30-0x39 for the 4th byte
GB18030 standard:
https://en.wikipedia.org/wiki/GB_18030
https://pan.baidu.com/share/link?shareid=2606985291&uk=3341026630
The current code forgets to check 0xFE for the 1st and 3rd byte.
Therefore, there are 8630 illegal 4-byte sequences can be decoded by GB18030 codec, here is an example:
# legal sequence b'\x81\x31\x81\x30' is decoded to U+060A, it's fine.
uchar = b'\x81\x31\x81\x30'.decode('gb18030')
print(hex(ord(uchar)))
# illegal sequence 0x8130FF30 can be decoded to U+060A as well, this should not happen.
uchar = b'\x81\x30\xFF\x30' .decode('gb18030')
print(hex(ord(uchar))) |
|
Date |
User |
Action |
Args |
2017-04-05 03:50:03 | malin | set | recipients:
+ malin, vstinner, ezio.melotti |
2017-04-05 03:50:03 | malin | set | messageid: <1491364203.61.0.947006759836.issue29990@psf.upfronthosting.co.za> |
2017-04-05 03:50:03 | malin | link | issue29990 messages |
2017-04-05 03:50:02 | malin | create | |
|