diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-06-11 21:48:02 +0000 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-06-11 21:48:02 +0000 |
commit | 4595e518178f547966fab079351a77d11566cf33 (patch) | |
tree | 9e127ec23cd12c2ec6b83fe738ef21ff61b3cf81 /Lib/test/test_codecs.py | |
parent | 59c9fa106aebd96bc36ae39bfa68059028f235ef (diff) | |
download | cpython-git-4595e518178f547966fab079351a77d11566cf33.tar.gz |
Merged revisions 81907 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r81907 | antoine.pitrou | 2010-06-11 23:42:26 +0200 (ven., 11 juin 2010) | 5 lines
Issue #8941: decoding big endian UTF-32 data in UCS-2 builds could crash
the interpreter with characters outside the Basic Multilingual Plane
(higher than 0x10000).
........
Diffstat (limited to 'Lib/test/test_codecs.py')
-rw-r--r-- | Lib/test/test_codecs.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index a46edae8fd..4d03ae735d 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -315,6 +315,16 @@ class UTF32Test(ReadTest): self.assertRaises(UnicodeDecodeError, codecs.utf_32_decode, "\xff", "strict", True) + def test_issue8941(self): + # Issue #8941: insufficient result allocation when decoding into + # surrogate pairs on UCS-2 builds. + encoded_le = '\xff\xfe\x00\x00' + '\x00\x00\x01\x00' * 1024 + self.assertEqual(u'\U00010000' * 1024, + codecs.utf_32_decode(encoded_le)[0]) + encoded_be = '\x00\x00\xfe\xff' + '\x00\x01\x00\x00' * 1024 + self.assertEqual(u'\U00010000' * 1024, + codecs.utf_32_decode(encoded_be)[0]) + class UTF32LETest(ReadTest): encoding = "utf-32-le" @@ -348,6 +358,13 @@ class UTF32LETest(ReadTest): self.assertRaises(UnicodeDecodeError, codecs.utf_32_le_decode, "\xff", "strict", True) + def test_issue8941(self): + # Issue #8941: insufficient result allocation when decoding into + # surrogate pairs on UCS-2 builds. + encoded = '\x00\x00\x01\x00' * 1024 + self.assertEqual(u'\U00010000' * 1024, + codecs.utf_32_le_decode(encoded)[0]) + class UTF32BETest(ReadTest): encoding = "utf-32-be" @@ -381,6 +398,14 @@ class UTF32BETest(ReadTest): self.assertRaises(UnicodeDecodeError, codecs.utf_32_be_decode, "\xff", "strict", True) + def test_issue8941(self): + # Issue #8941: insufficient result allocation when decoding into + # surrogate pairs on UCS-2 builds. + encoded = '\x00\x01\x00\x00' * 1024 + self.assertEqual(u'\U00010000' * 1024, + codecs.utf_32_be_decode(encoded)[0]) + + class UTF16Test(ReadTest): encoding = "utf-16" |