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

Email parse IndexError <""@wiarcom.com> #72118

Closed
ghost opened this issue Sep 1, 2016 · 13 comments
Closed

Email parse IndexError <""@wiarcom.com> #72118

ghost opened this issue Sep 1, 2016 · 13 comments
Assignees
Labels
3.7 (EOL) end of life topic-email type-bug An unexpected behavior, bug, or error

Comments

@ghost
Copy link

ghost commented Sep 1, 2016

BPO 27931
Nosy @warsaw, @bitdancer, @zhangyangyu, @Mariatta, @jayyyin
PRs
  • bpo-27931: Fix email address header parsing error #5329
  • [3.6] bpo-27931: Fix email address header parsing error (GH-5329) #5431
  • Files
  • issue27931.patch
  • issue27931.patch
  • issue27931_v2.patch
  • 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 = 'https://github.com/bitdancer'
    closed_at = <Date 2018-01-30.01:10:30.380>
    created_at = <Date 2016-09-01.15:29:39.045>
    labels = ['type-bug', '3.7', 'expert-email']
    title = 'Email parse IndexError <""@wiarcom.com>'
    updated_at = <Date 2018-01-30.01:10:30.379>
    user = None

    bugs.python.org fields:

    activity = <Date 2018-01-30.01:10:30.379>
    actor = 'xiang.zhang'
    assignee = 'r.david.murray'
    closed = True
    closed_date = <Date 2018-01-30.01:10:30.380>
    closer = 'xiang.zhang'
    components = ['email']
    creation = <Date 2016-09-01.15:29:39.045>
    creator = '\xd0\x9a\xd0\xbe\xd0\xbd\xd1\x81\xd1\x82\xd0\xb0\xd0\xbd\xd1\x82\xd0\xb8\xd0\xbd \xd0\x92\xd0\xbe\xd0\xbb\xd0\xba\xd0\xbe\xd0\xb2'
    dependencies = []
    files = ['44340', '44516', '44523']
    hgrepos = []
    issue_num = 27931
    keywords = ['patch']
    message_count = 13.0
    messages = ['274140', '274207', '274245', '274260', '275238', '275513', '275572', '278839', '285042', '307328', '310761', '311154', '311187']
    nosy_count = 6.0
    nosy_names = ['barry', 'r.david.murray', 'xiang.zhang', '\xd0\x9a\xd0\xbe\xd0\xbd\xd1\x81\xd1\x82\xd0\xb0\xd0\xbd\xd1\x82\xd0\xb8\xd0\xbd \xd0\x92\xd0\xbe\xd0\xbb\xd0\xba\xd0\xbe\xd0\xb2', 'Mariatta', 'jayyin11043']
    pr_nums = ['5329', '5431']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue27931'
    versions = ['Python 3.6', 'Python 3.7']

    @ghost
    Copy link
    Author

    ghost commented Sep 1, 2016

    Email lib fails to parse some emails:

    from email._header_value_parser import get_angle_addr    get_angle_addr('<""@wiarcom.com> SIZE=28113').addr_spec

    IndexError: list index out of range

    Seems that email address can be parsed.

    Repository owner added the topic-email label Sep 1, 2016
    @zhangyangyu
    Copy link
    Member

    Looking at the spec this is a valid angle addr. Not only et_angle_addr('<""@wiarcom.com> SIZE=28113')[0].addr_spec but also et_angle_addr('<""@wiarcom.com> SIZE=28113')[0].local_part fails for the same reason.

    The problem exists in get_bare_quoted_string. When encounter bare '""', it returns a empty BareQuoteString. I write bpo-27931.patch to fix this.

    @bitdancer
    Copy link
    Member

    You are correct, it is technically a valid angleaddr. I'll review this next week, the patch looks good (thanks) but I need to double check a couple things before I commit.

    @bitdancer bitdancer self-assigned this Sep 2, 2016
    @zhangyangyu
    Copy link
    Member

    It should be. If there is anything wrong I'd like to hear and fix.

    @zhangyangyu
    Copy link
    Member

    Ping this and hope you don't forget about it David. :)

    @bitdancer
    Copy link
    Member

    Reviewed. There is something else that needs fixing. The address needs to re-render as ""@wiarcom.com, which it doesn't currently. I scanned the rendering code in _header_value_registry quickly and its not obvious to me why it doesn't work, so it may be a bug in the headerregistry.Address object. I'm uploading the patch with the added test.

    @zhangyangyu
    Copy link
    Member

    You are right David. But I don't understand what it has to do with headerregistry. I update my original patch to get that behaviour, limit it the affection in angleaddr. Now seems everything is fine.

    >>> email._header_value_parser.get_angle_addr('<""@wiarcom.com> SIZE=28113')[0].local_part
    ''
    >>> email._header_value_parser.get_angle_addr('<""@wiarcom.com> SIZE=28113')[0].domain
    'wiarcom.com'
    >>> email._header_value_parser.get_angle_addr('<""@wiarcom.com> SIZE=28113')[0].route
    >>> email._header_value_parser.get_angle_addr('<""@wiarcom.com> SIZE=28113')[0].addr_spec
    '""@wiarcom.com'

    @zhangyangyu
    Copy link
    Member

    Ping.

    @ghost
    Copy link
    Author

    ghost commented Jan 9, 2017

    ping

    1 similar comment
    @ghost
    Copy link
    Author

    ghost commented Nov 30, 2017

    ping

    @zhangyangyu zhangyangyu added 3.7 (EOL) end of life type-bug An unexpected behavior, bug, or error labels Jan 26, 2018
    @jayyyin
    Copy link
    Mannequin

    jayyyin mannequin commented Jan 26, 2018

    #5329
    this is the pending pull request for this

    @bitdancer
    Copy link
    Member

    New changeset aa218d1 by R. David Murray (jayyyin) in branch 'master':
    bpo-27931: Fix email address header parsing error (bpo-5329)
    aa218d1

    @Mariatta
    Copy link
    Member

    New changeset 6ea75b1 by Mariatta (Miss Islington (bot)) in branch '3.6':
    bpo-27931: Fix email address header parsing error (GH-5329) (GH-5431)
    6ea75b1

    @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
    3.7 (EOL) end of life topic-email type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants