diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2014-02-08 12:01:29 (GMT) |
|---|---|---|
| committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-02-08 12:01:29 (GMT) |
| commit | 016a3f33a533bdec6977639bfa83b7f93f6c8c88 (patch) | |
| tree | d0f6562afddc85754ba5bcb0637a74d21b86fad0 /Objects/unicodeobject.c | |
| parent | 1e949890f618867b7eabc1c08873611e960f5d03 (diff) | |
| download | cpython-016a3f33a533bdec6977639bfa83b7f93f6c8c88.zip cpython-016a3f33a533bdec6977639bfa83b7f93f6c8c88.tar.gz cpython-016a3f33a533bdec6977639bfa83b7f93f6c8c88.tar.bz2 | |
Issue #20538: UTF-7 incremental decoder produced inconsistant string when
input was truncated in BASE64 section.
Diffstat (limited to 'Objects/unicodeobject.c')
| -rw-r--r-- | Objects/unicodeobject.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index a149177..beafaa4 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -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; |
