mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +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
|
@ -1520,13 +1520,18 @@ def get_obs_local_part(value):
|
|||
raise
|
||||
token, value = get_cfws(value)
|
||||
obs_local_part.append(token)
|
||||
if not obs_local_part:
|
||||
raise errors.HeaderParseError(
|
||||
"expected obs-local-part but found '{}'".format(value))
|
||||
if (obs_local_part[0].token_type == 'dot' or
|
||||
obs_local_part[0].token_type=='cfws' and
|
||||
len(obs_local_part) > 1 and
|
||||
obs_local_part[1].token_type=='dot'):
|
||||
obs_local_part.defects.append(errors.InvalidHeaderDefect(
|
||||
"Invalid leading '.' in local part"))
|
||||
if (obs_local_part[-1].token_type == 'dot' or
|
||||
obs_local_part[-1].token_type=='cfws' and
|
||||
len(obs_local_part) > 1 and
|
||||
obs_local_part[-2].token_type=='dot'):
|
||||
obs_local_part.defects.append(errors.InvalidHeaderDefect(
|
||||
"Invalid trailing '.' in local part"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue