summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_email
diff options
context:
space:
mode:
authorAbhilash Raj <maxking@users.noreply.github.com>2019-12-09 01:37:34 (GMT)
committerGitHub <noreply@github.com>2019-12-09 01:37:34 (GMT)
commit3ae4ea1931361dd2743e464790e739d9285501bf (patch)
tree56b73bd2a05fc6f53d9cbb0ad9cfb72547b97111 /Lib/test/test_email
parent68157da8b42b26408af5d157d2dba4fcf29c6320 (diff)
downloadcpython-3ae4ea1931361dd2743e464790e739d9285501bf.zip
cpython-3ae4ea1931361dd2743e464790e739d9285501bf.tar.gz
cpython-3ae4ea1931361dd2743e464790e739d9285501bf.tar.bz2
bpo-38708: email: Fix a potential IndexError when parsing Message-ID (GH-17504)
Fix a potential IndexError when passing an empty value to the message-id parser. Instead, HeaderParseError should be raised.
Diffstat (limited to 'Lib/test/test_email')
-rw-r--r--Lib/test/test_email/test__header_value_parser.py6
1 files changed, 6 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 d59d701..1bdcfa1 100644
--- a/Lib/test/test_email/test__header_value_parser.py
+++ b/Lib/test/test_email/test__header_value_parser.py
@@ -2583,6 +2583,11 @@ class TestParser(TestParserMixin, TestEmailBase):
# get_msg_id
+ def test_get_msg_id_empty(self):
+ # bpo-38708: Test that HeaderParseError is raised and not IndexError.
+ with self.assertRaises(errors.HeaderParseError):
+ parser.get_msg_id('')
+
def test_get_msg_id_valid(self):
msg_id = self._test_get_x(
parser.get_msg_id,
@@ -2694,6 +2699,7 @@ class TestParser(TestParserMixin, TestEmailBase):
self.assertEqual(msg_id.token_type, 'msg-id')
+
@parameterize
class Test_parse_mime_parameters(TestParserMixin, TestEmailBase):