mailarchive icon indicating copy to clipboard operation
mailarchive copied to clipboard

Malformed header causes message import failure

Open rpcross opened this issue 2 years ago • 0 comments

Example: ... From: RFC Errata System [email protected] Cc: [email protected], 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.

rpcross avatar Jul 13 '22 16:07 rpcross