mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
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
3 changed files with 45 additions and 7 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue