summaryrefslogtreecommitdiffstats
path: root/Lib/email/_header_value_parser.py
diff options
context:
space:
mode:
authorAndrei Troie <andreitroie90@gmail.com>2019-10-05 16:19:15 (GMT)
committerAbhilash Raj <maxking@users.noreply.github.com>2019-10-05 16:19:15 (GMT)
commit65dcc8a8dc41d3453fd6b987073a5f1b30c5c0fd (patch)
tree95dc8edc797c00bcc5a8020e63268fbc0009975b /Lib/email/_header_value_parser.py
parent3faf826e5879536d2272f1a51c58965a16827f81 (diff)
downloadcpython-65dcc8a8dc41d3453fd6b987073a5f1b30c5c0fd.zip
cpython-65dcc8a8dc41d3453fd6b987073a5f1b30c5c0fd.tar.gz
cpython-65dcc8a8dc41d3453fd6b987073a5f1b30c5c0fd.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.
Diffstat (limited to 'Lib/email/_header_value_parser.py')
-rw-r--r--Lib/email/_header_value_parser.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py
index 16c1990..1668b4a 100644
--- a/Lib/email/_header_value_parser.py
+++ b/Lib/email/_header_value_parser.py
@@ -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