summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_email
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_email')
-rw-r--r--Lib/test/test_email/test__encoded_words.py2
-rw-r--r--Lib/test/test_email/test__header_value_parser.py12
2 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_email/test__encoded_words.py b/Lib/test/test_email/test__encoded_words.py
index 5a59aeb..0b8b1de 100644
--- a/Lib/test/test_email/test__encoded_words.py
+++ b/Lib/test/test_email/test__encoded_words.py
@@ -58,6 +58,8 @@ class TestDecode(TestEmailBase):
_ew.decode('=?')
with self.assertRaises(ValueError):
_ew.decode('')
+ with self.assertRaises(KeyError):
+ _ew.decode('=?utf-8?X?somevalue?=')
def _test(self, source, result, charset='us-ascii', lang='', defects=[]):
res, char, l, d = _ew.decode(source)
diff --git a/Lib/test/test_email/test__header_value_parser.py b/Lib/test/test_email/test__header_value_parser.py
index 058d902..46d90b3 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):