mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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.
This commit is contained in:
parent
3faf826e58
commit
65dcc8a8dc
4 changed files with 18 additions and 1 deletions
|
@ -1057,7 +1057,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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue