mirror of
https://github.com/python/cpython.git
synced 2025-11-11 11:01:39 +00:00
gh-86650: Fix IndexError when parse emails with invalid Message-ID (GH-117934)
In particularly, one-off addresses generated by Microsoft Outlook: https://learn.microsoft.com/en-us/office/client-developer/outlook/mapi/one-off-addresses Co-authored-by: fsc-eriker <72394365+fsc-eriker@users.noreply.github.com>
This commit is contained in:
parent
8cc9adbfdd
commit
f74e51229c
3 changed files with 32 additions and 0 deletions
|
|
@ -2724,6 +2724,31 @@ def test_get_msg_id_no_angle_end(self):
|
|||
)
|
||||
self.assertEqual(msg_id.token_type, 'msg-id')
|
||||
|
||||
def test_get_msg_id_empty_id_left(self):
|
||||
with self.assertRaises(errors.HeaderParseError):
|
||||
parser.get_msg_id("<@domain>")
|
||||
|
||||
def test_get_msg_id_empty_id_right(self):
|
||||
with self.assertRaises(errors.HeaderParseError):
|
||||
parser.get_msg_id("<simplelocal@>")
|
||||
|
||||
def test_get_msg_id_with_brackets(self):
|
||||
# Microsof Outlook generates non-standard one-off addresses:
|
||||
# https://learn.microsoft.com/en-us/office/client-developer/outlook/mapi/one-off-addresses
|
||||
with self.assertRaises(errors.HeaderParseError):
|
||||
parser.get_msg_id("<[abrakadabra@microsoft.com]>")
|
||||
|
||||
def test_get_msg_id_ws_only_local(self):
|
||||
msg_id = self._test_get_x(
|
||||
parser.get_msg_id,
|
||||
"< @domain>",
|
||||
"< @domain>",
|
||||
"< @domain>",
|
||||
[errors.ObsoleteHeaderDefect],
|
||||
""
|
||||
)
|
||||
self.assertEqual(msg_id.token_type, 'msg-id')
|
||||
|
||||
|
||||
|
||||
@parameterize
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue