summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-11-15 00:44:16 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-11-15 00:44:16 (GMT)
commit78edf7576e4bef16a5eda86cbbb912f5ffb208ec (patch)
tree64affea863ba10d3cd0b588254818d7813aaafa6 /Objects
parent9a812cbc899caeb25ab523e904dfac02e4da2999 (diff)
parent5418ee0b9a36886064937159f9c0641ae2c4f618 (diff)
downloadcpython-78edf7576e4bef16a5eda86cbbb912f5ffb208ec.zip
cpython-78edf7576e4bef16a5eda86cbbb912f5ffb208ec.tar.gz
cpython-78edf7576e4bef16a5eda86cbbb912f5ffb208ec.tar.bz2
Issue #13333: The UTF-7 decoder now accepts lone surrogates
(the encoder already accepts them).
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 6b245aa..cdad738 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -3884,21 +3884,18 @@ PyUnicode_DecodeUTF7Stateful(const char *s,
if (unicode_putchar(&unicode, &outpos, ch2) < 0)
goto onError;
surrogate = 0;
+ continue;
}
else {
+ if (unicode_putchar(&unicode, &outpos, surrogate) < 0)
+ goto onError;
surrogate = 0;
- errmsg = "second surrogate missing";
- goto utf7Error;
}
}
- else if (outCh >= 0xD800 && outCh <= 0xDBFF) {
+ if (outCh >= 0xD800 && outCh <= 0xDBFF) {
/* first surrogate */
surrogate = outCh;
}
- else if (outCh >= 0xDC00 && outCh <= 0xDFFF) {
- errmsg = "unexpected second surrogate";
- goto utf7Error;
- }
else {
if (unicode_putchar(&unicode, &outpos, outCh) < 0)
goto onError;
@@ -3909,8 +3906,9 @@ PyUnicode_DecodeUTF7Stateful(const char *s,
inShift = 0;
s++;
if (surrogate) {
- errmsg = "second surrogate missing at end of shift sequence";
- goto utf7Error;
+ if (unicode_putchar(&unicode, &outpos, surrogate) < 0)
+ goto onError;
+ surrogate = 0;
}
if (base64bits > 0) { /* left-over bits */
if (base64bits >= 6) {