Skip to content

email index error parsing address header ending in'"' #148518

@bitdancer

Description

@bitdancer

Bug report

Bug description:

I encountered this while working on improving the header_value_parser tests. This is an unlikely edge case. After fixing it, we can fix a little niggle in the header parser (see PR).

>>> from email import message_from_string
>>> from email.policy import default
>>> m = message_from_string('To: "\n\n', policy=default)
>>> m['to'].mailboxes.username
Traceback (most recent call last):
   ...
  File "/home/rdmurray/cpython/main/Lib/email/_header_value_parser.py", line 647, in local_part
    tok[0].token_type == 'cfws'):
    ~~~^^^
IndexError: list index out of range

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Metadata

Metadata

Assignees

Labels

stdlibStandard Library Python modules in the Lib/ directorytopic-emailtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions