This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Empty email address in headers triggers an IndexError
Type: behavior Stage: resolved
Components: email Versions: Python 3.6, Python 3.4, Python 3.5
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: barry, cheryl.sabella, maxking, mtorromeo, r.david.murray
Priority: normal Keywords:

Created on 2017-11-30 11:27 by mtorromeo, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4644 closed mtorromeo, 2017-11-30 11:27
Messages (4)
msg307292 - (view) Author: Massimiliano Torromeo (mtorromeo) * Date: 2017-11-30 11:27
In case an address email header contains and empty string, the tokenizer return a BareQuotedString
which is also a TokenList, but this list is empty and the parser fails to check this and insteads raises an IndexError.

For example an email with this header will trigger the IndexError:
ReplyTo: ""
msg345628 - (view) Author: Abhilash Raj (maxking) * (Python committer) Date: 2019-06-14 18:45
I wasn't able to reproduce this on the latest master. Probably fixed as a part of some other PR.

    >>> msg = email.message_from_string('ReplyTo: ""')
    >>> msg
    <email.message.Message object at 0x7f1fc6c82eb0>
    >>> msg['ReplyTo']

I think this issue can be closed.
msg347249 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2019-07-03 23:51
Closing this per @maxking's comment.  If it can be recreated, please reopen.
msg347588 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2019-07-10 01:03
BareQuotedString implies the new API is being used, though that was not made clear in the report.  However, unlike the other recently closed issue, this one was in fact fixed (and I have a vague memory of reviewing the PR):

>>> m = message_from_string('ReplyTo: ""', policy=default)
>>> m['ReplyTo']
Date User Action Args
2022-04-11 14:58:55adminsetgithub: 76360
2019-07-10 01:03:23r.david.murraysetmessages: + msg347588
2019-07-03 23:51:25cheryl.sabellasetstatus: open -> closed

nosy: + cheryl.sabella
messages: + msg347249

resolution: out of date
stage: resolved
2019-06-14 18:45:08maxkingsetnosy: + maxking
messages: + msg345628
2017-11-30 11:27:18mtorromeocreate