diff options
author | Zackery Spytz <zspytz@gmail.com> | 2018-08-19 04:43:38 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2018-08-19 04:43:38 (GMT) |
commit | e349bf23584eef20e0d1e1b2989d9b1430f15507 (patch) | |
tree | d698b962c27f07d0e6f1baf4fbe13fee145c60dc /Objects/unicodeobject.c | |
parent | d3d3171da895d8cb880f23fae6be778f0ac23be7 (diff) | |
download | cpython-e349bf23584eef20e0d1e1b2989d9b1430f15507.zip cpython-e349bf23584eef20e0d1e1b2989d9b1430f15507.tar.gz cpython-e349bf23584eef20e0d1e1b2989d9b1430f15507.tar.bz2 |
bpo-22602: Raise an exception in the UTF-7 decoder for ill-formed sequences starting with "+". (GH-8741)
The UTF-7 decoder now raises UnicodeDecodeError for ill-formed
sequences starting with "+" (as specified in RFC 2152).
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 04fd6d0..0460d18 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -4479,6 +4479,11 @@ PyUnicode_DecodeUTF7Stateful(const char *s, if (_PyUnicodeWriter_WriteCharInline(&writer, '+') < 0) goto onError; } + else if (s < e && !IS_BASE64(*s)) { + s++; + errmsg = "ill-formed sequence"; + goto utf7Error; + } else { /* begin base64-encoded section */ inShift = 1; surrogate = 0; |