mirror of https://github.com/python/cpython.git
Issue #20538: UTF-7 incremental decoder produced inconsistant string when
input was truncated in BASE64 section.
This commit is contained in:
parent
1e949890f6
commit
016a3f33a5
|
@ -852,13 +852,40 @@ class UTF7Test(ReadTest, unittest.TestCase):
|
||||||
|
|
||||||
def test_partial(self):
|
def test_partial(self):
|
||||||
self.check_partial(
|
self.check_partial(
|
||||||
"a+-b",
|
'a+-b\x00c\x80d\u0100e\U00010000f',
|
||||||
[
|
[
|
||||||
"a",
|
'a',
|
||||||
"a",
|
'a',
|
||||||
"a+",
|
'a+',
|
||||||
"a+-",
|
'a+-',
|
||||||
"a+-b",
|
'a+-b',
|
||||||
|
'a+-b',
|
||||||
|
'a+-b',
|
||||||
|
'a+-b',
|
||||||
|
'a+-b',
|
||||||
|
'a+-b\x00',
|
||||||
|
'a+-b\x00c',
|
||||||
|
'a+-b\x00c',
|
||||||
|
'a+-b\x00c',
|
||||||
|
'a+-b\x00c',
|
||||||
|
'a+-b\x00c',
|
||||||
|
'a+-b\x00c\x80',
|
||||||
|
'a+-b\x00c\x80d',
|
||||||
|
'a+-b\x00c\x80d',
|
||||||
|
'a+-b\x00c\x80d',
|
||||||
|
'a+-b\x00c\x80d',
|
||||||
|
'a+-b\x00c\x80d',
|
||||||
|
'a+-b\x00c\x80d\u0100',
|
||||||
|
'a+-b\x00c\x80d\u0100e',
|
||||||
|
'a+-b\x00c\x80d\u0100e',
|
||||||
|
'a+-b\x00c\x80d\u0100e',
|
||||||
|
'a+-b\x00c\x80d\u0100e',
|
||||||
|
'a+-b\x00c\x80d\u0100e',
|
||||||
|
'a+-b\x00c\x80d\u0100e',
|
||||||
|
'a+-b\x00c\x80d\u0100e',
|
||||||
|
'a+-b\x00c\x80d\u0100e',
|
||||||
|
'a+-b\x00c\x80d\u0100e\U00010000',
|
||||||
|
'a+-b\x00c\x80d\u0100e\U00010000f',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,9 @@ What's New in Python 3.3.4 release candidate 1?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #20538: UTF-7 incremental decoder produced inconsistant string when
|
||||||
|
input was truncated in BASE64 section.
|
||||||
|
|
||||||
- Issue #17825: Cursor "^" is correctly positioned for SyntaxError and
|
- Issue #17825: Cursor "^" is correctly positioned for SyntaxError and
|
||||||
IndentationError.
|
IndentationError.
|
||||||
|
|
||||||
|
|
|
@ -4474,8 +4474,16 @@ PyUnicode_DecodeUTF7Stateful(const char *s,
|
||||||
/* return state */
|
/* return state */
|
||||||
if (consumed) {
|
if (consumed) {
|
||||||
if (inShift) {
|
if (inShift) {
|
||||||
outpos = shiftOutStart; /* back off output */
|
|
||||||
*consumed = startinpos;
|
*consumed = startinpos;
|
||||||
|
if (outpos != shiftOutStart &&
|
||||||
|
PyUnicode_MAX_CHAR_VALUE(unicode) > 127) {
|
||||||
|
PyObject *result = PyUnicode_FromKindAndData(
|
||||||
|
PyUnicode_KIND(unicode), PyUnicode_DATA(unicode),
|
||||||
|
shiftOutStart);
|
||||||
|
Py_DECREF(unicode);
|
||||||
|
unicode = result;
|
||||||
|
}
|
||||||
|
outpos = shiftOutStart; /* back off output */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*consumed = s-starts;
|
*consumed = s-starts;
|
||||||
|
|
Loading…
Reference in New Issue