diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-10-12 17:02:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-12 17:02:23 (GMT) |
commit | febe359559781019c0c8432a2f768809d00af6af (patch) | |
tree | 0d7807aebf421f77724108bfeb57c3cb355466cd /Lib/email/_header_value_parser.py | |
parent | cb580d6fa8349acff723a7a044181d896d076871 (diff) | |
download | cpython-febe359559781019c0c8432a2f768809d00af6af.zip cpython-febe359559781019c0c8432a2f768809d00af6af.tar.gz cpython-febe359559781019c0c8432a2f768809d00af6af.tar.bz2 |
bpo-38332: Catch KeyError from unknown cte in encoded-word. (GH-16503)
KeyError should cause a failure in parsing the encoded word and should be caught and raised as a _InvalidEWError instead.
(cherry picked from commit 65dcc8a8dc41d3453fd6b987073a5f1b30c5c0fd)
Co-authored-by: Andrei Troie <andreitroie90@gmail.com>
Diffstat (limited to 'Lib/email/_header_value_parser.py')
-rw-r--r-- | Lib/email/_header_value_parser.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py index 7cc9a46..3197d49 100644 --- a/Lib/email/_header_value_parser.py +++ b/Lib/email/_header_value_parser.py @@ -1055,7 +1055,7 @@ def get_encoded_word(value): value = ''.join(remainder) try: text, charset, lang, defects = _ew.decode('=?' + tok + '?=') - except ValueError: + except (ValueError, KeyError): raise _InvalidEwError( "encoded word format invalid: '{}'".format(ew.cte)) ew.charset = charset |