mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +00:00
Issue #6922: Fix an infinite loop when trying to decode an invalid
UTF-32 stream with a non-raising error handler like "replace" or "ignore".
This commit is contained in:
parent
bc3777d85e
commit
e9741f3ed8
3 changed files with 16 additions and 1 deletions
|
@ -305,6 +305,12 @@ class UTF32Test(ReadTest):
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_handlers(self):
|
||||||
|
self.assertEqual((u'\ufffd', 1),
|
||||||
|
codecs.utf_32_decode('\x01', 'replace', True))
|
||||||
|
self.assertEqual((u'', 1),
|
||||||
|
codecs.utf_32_decode('\x01', 'ignore', True))
|
||||||
|
|
||||||
def test_errors(self):
|
def test_errors(self):
|
||||||
self.assertRaises(UnicodeDecodeError, codecs.utf_32_decode,
|
self.assertRaises(UnicodeDecodeError, codecs.utf_32_decode,
|
||||||
"\xff", "strict", True)
|
"\xff", "strict", True)
|
||||||
|
@ -422,6 +428,12 @@ class UTF16Test(ReadTest):
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_handlers(self):
|
||||||
|
self.assertEqual((u'\ufffd', 1),
|
||||||
|
codecs.utf_16_decode('\x01', 'replace', True))
|
||||||
|
self.assertEqual((u'', 1),
|
||||||
|
codecs.utf_16_decode('\x01', 'ignore', True))
|
||||||
|
|
||||||
def test_errors(self):
|
def test_errors(self):
|
||||||
self.assertRaises(UnicodeDecodeError, codecs.utf_16_decode, "\xff", "strict", True)
|
self.assertRaises(UnicodeDecodeError, codecs.utf_16_decode, "\xff", "strict", True)
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,9 @@ What's New in Python 2.7 alpha 1
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #6922: Fix an infinite loop when trying to decode an invalid
|
||||||
|
UTF-32 stream with a non-raising error handler like "replace" or "ignore".
|
||||||
|
|
||||||
- Issue #6713: Improve performance of integer -> string conversions.
|
- Issue #6713: Improve performance of integer -> string conversions.
|
||||||
|
|
||||||
- Issue #1590864: Fix potential deadlock when mixing threads and fork().
|
- Issue #1590864: Fix potential deadlock when mixing threads and fork().
|
||||||
|
|
|
@ -2321,7 +2321,7 @@ PyUnicode_DecodeUTF32Stateful(const char *s,
|
||||||
if (unicode_decode_call_errorhandler(
|
if (unicode_decode_call_errorhandler(
|
||||||
errors, &errorHandler,
|
errors, &errorHandler,
|
||||||
"utf32", errmsg,
|
"utf32", errmsg,
|
||||||
starts, size, &startinpos, &endinpos, &exc, &s,
|
starts, size, &startinpos, &endinpos, &exc, (const char **)&q,
|
||||||
&unicode, &outpos, &p))
|
&unicode, &outpos, &p))
|
||||||
goto onError;
|
goto onError;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue