cpython: 7dde9c553f16 (original) (raw)

--- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -820,6 +820,36 @@ class UTF7Test(ReadTest, unittest.TestCa ] )

+

+ class UTF16ExTest(unittest.TestCase): def test_errors(self):

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ Projected release date: 2013-10-20 Core and Builtins ----------------- +- Issue #19279: UTF-7 decoder no more produces illegal strings. +

--- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -4341,6 +4341,7 @@ PyUnicode_DecodeUTF7Stateful(const char Py_UCS4 outCh = (Py_UCS4)(base64buffer >> (base64bits-16)); base64bits -= 16; base64buffer &= (1 << base64bits) - 1; /* clear high bits */

@@ -4408,6 +4409,7 @@ PyUnicode_DecodeUTF7Stateful(const char inShift = 1; shiftOutStart = writer.pos; base64bits = 0;