Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Malformed header causes message import failure #3510

Open
rpcross opened this issue Jul 13, 2022 · 0 comments
Open

Malformed header causes message import failure #3510

rpcross opened this issue Jul 13, 2022 · 0 comments

Comments

@rpcross
Copy link
Collaborator

rpcross commented Jul 13, 2022

Example:
...
From: RFC Errata System rfc-editor@rfc-editor.org
Cc: example@gmail.com,
Content-Type: text/plain; charset=UTF-8
...

The Cc: value with a trailing comma causes a failure.

To Reproduce:
NO_REFOLD_POLICY = policy.SMTP.clone(refold_source='none')
with open('path', 'rb') as f:
data = f.read()
msg = email.message_from_bytes(data, policy=NO_REFOLD_POLICY)
msg.items()
...
File "/usr/lib64/python3.6/email/_header_value_parser.py", line 1365, in get_phrase
token, value = get_word(value)
File "/usr/lib64/python3.6/email/_header_value_parser.py", line 1340, in get_word
if value[0]=='"':
IndexError: string index out of range

Interestingly this doesn't happen when not specifying policy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant