Issue #20538: UTF-7 incremental decoder produced inconsistant string when

input was truncated in BASE64 section.
This commit is contained in:
Serhiy Storchaka 2014-02-08 14:01:29 +02:00
parent 1e949890f6
commit 016a3f33a5
3 changed files with 45 additions and 7 deletions

View file

@ -4474,8 +4474,16 @@ utf7Error:
/* return state */
if (consumed) {
if (inShift) {
outpos = shiftOutStart; /* back off output */
*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 {
*consumed = s-starts;