summaryrefslogtreecommitdiff
path: root/Lib/test/test_email/test__header_value_parser.py
diff options
context:
space:
mode:
authorAndrei Troie <andreitroie90@gmail.com>2019-10-05 17:19:15 +0100
committerAbhilash Raj <maxking@users.noreply.github.com>2019-10-05 09:19:15 -0700
commit65dcc8a8dc41d3453fd6b987073a5f1b30c5c0fd (patch)
tree95dc8edc797c00bcc5a8020e63268fbc0009975b /Lib/test/test_email/test__header_value_parser.py
parent3faf826e5879536d2272f1a51c58965a16827f81 (diff)
downloadcpython-git-65dcc8a8dc41d3453fd6b987073a5f1b30c5c0fd.tar.gz
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/test/test_email/test__header_value_parser.py')
-rw-r--r--Lib/test/test_email/test__header_value_parser.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_email/test__header_value_parser.py b/Lib/test/test_email/test__header_value_parser.py
index 058d902459..46d90b38e9 100644
--- a/Lib/test/test_email/test__header_value_parser.py
+++ b/Lib/test/test_email/test__header_value_parser.py
@@ -89,6 +89,10 @@ class TestParser(TestParserMixin, TestEmailBase):
with self.assertRaises(errors.HeaderParseError):
parser.get_encoded_word('=?abc?=')
+ def test_get_encoded_word_invalid_cte(self):
+ with self.assertRaises(errors.HeaderParseError):
+ parser.get_encoded_word('=?utf-8?X?somevalue?=')
+
def test_get_encoded_word_valid_ew(self):
self._test_get_x(parser.get_encoded_word,
'=?us-ascii?q?this_is_a_test?= bird',
@@ -399,6 +403,14 @@ class TestParser(TestParserMixin, TestEmailBase):
[],
'')
+ def test_get_unstructured_invalid_ew_cte(self):
+ self._test_get_x(self._get_unst,
+ '=?utf-8?X?=somevalue?=',
+ '=?utf-8?X?=somevalue?=',
+ '=?utf-8?X?=somevalue?=',
+ [],
+ '')
+
# get_qp_ctext
def test_get_qp_ctext_only(self):