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

Empty email address in headers triggers an IndexError #76360

Closed
mtorromeo mannequin opened this issue Nov 30, 2017 · 4 comments
Closed

Empty email address in headers triggers an IndexError #76360

mtorromeo mannequin opened this issue Nov 30, 2017 · 4 comments
Labels
topic-email type-bug An unexpected behavior, bug, or error

Comments

@mtorromeo
Copy link
Mannequin

mtorromeo mannequin commented Nov 30, 2017

BPO 32179
Nosy @warsaw, @bitdancer, @maxking, @csabella, @mtorromeo
PRs
  • bpo-32179: Fix handling of empty email address in header parsing #4644
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-07-03.23:51:25.071>
    created_at = <Date 2017-11-30.11:27:18.103>
    labels = ['type-bug', 'expert-email']
    title = 'Empty email address in headers triggers an IndexError'
    updated_at = <Date 2019-07-10.01:03:23.456>
    user = 'https://github.com/mtorromeo'

    bugs.python.org fields:

    activity = <Date 2019-07-10.01:03:23.456>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-07-03.23:51:25.071>
    closer = 'cheryl.sabella'
    components = ['email']
    creation = <Date 2017-11-30.11:27:18.103>
    creator = 'mtorromeo'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32179
    keywords = []
    message_count = 4.0
    messages = ['307292', '345628', '347249', '347588']
    nosy_count = 5.0
    nosy_names = ['barry', 'r.david.murray', 'maxking', 'cheryl.sabella', 'mtorromeo']
    pr_nums = ['4644']
    priority = 'normal'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue32179'
    versions = ['Python 3.4', 'Python 3.5', 'Python 3.6']

    @mtorromeo
    Copy link
    Mannequin Author

    mtorromeo mannequin commented Nov 30, 2017

    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: ""

    @mtorromeo mtorromeo mannequin added topic-email type-bug An unexpected behavior, bug, or error labels Nov 30, 2017
    @maxking
    Copy link
    Contributor

    maxking commented Jun 14, 2019

    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.

    @csabella
    Copy link
    Contributor

    csabella commented Jul 3, 2019

    Closing this per @maxking's comment. If it can be recreated, please reopen.

    @csabella csabella closed this as completed Jul 3, 2019
    @bitdancer
    Copy link
    Member

    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']
    '""'

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-email type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants