summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-10-12 17:03:24 (GMT)
committerGitHub <noreply@github.com>2019-10-12 17:03:24 (GMT)
commite540bb546163f108c7c304f2e6865efaa78cd4c2 (patch)
tree1b0e2708798443858100a7b42181eaa47df93af3 /Lib/email
parent5a638a805503131f4a9cc2bbc5944611295c1500 (diff)
downloadcpython-e540bb546163f108c7c304f2e6865efaa78cd4c2.zip
cpython-e540bb546163f108c7c304f2e6865efaa78cd4c2.tar.gz
cpython-e540bb546163f108c7c304f2e6865efaa78cd4c2.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')
-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