diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-11-15 00:42:21 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-11-15 00:42:21 (GMT) |
commit | 5418ee0b9a36886064937159f9c0641ae2c4f618 (patch) | |
tree | 5602bfce8d5bea5b17deee14207d2a238170489a /Objects | |
parent | c2fe57762b6cfa8849908e1a0475036cd0b058ba (diff) | |
download | cpython-5418ee0b9a36886064937159f9c0641ae2c4f618.zip cpython-5418ee0b9a36886064937159f9c0641ae2c4f618.tar.gz cpython-5418ee0b9a36886064937159f9c0641ae2c4f618.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.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 7316abf..8680726 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -2282,21 +2282,17 @@ PyObject *PyUnicode_DecodeUTF7Stateful(const char *s, *p++ = outCh; #endif surrogate = 0; + continue; } else { + *p++ = surrogate; 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 { *p++ = outCh; } @@ -2306,8 +2302,8 @@ PyObject *PyUnicode_DecodeUTF7Stateful(const char *s, inShift = 0; s++; if (surrogate) { - errmsg = "second surrogate missing at end of shift sequence"; - goto utf7Error; + *p++ = surrogate; + surrogate = 0; } if (base64bits > 0) { /* left-over bits */ if (base64bits >= 6) { |