classification
Title: Email parse IndexError <""@wiarcom.com>
Type: behavior Stage: resolved
Components: email Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: r.david.murray Nosy List: Mariatta, barry, jayyin11043, r.david.murray, xiang.zhang, Константин Волков
Priority: normal Keywords: patch

Created on 2016-09-01 15:29 by Константин Волков, last changed 2018-01-30 01:10 by xiang.zhang. This issue is now closed.

Files
File name Uploaded Description Edit
issue27931.patch xiang.zhang, 2016-09-02 07:45 review
issue27931.patch r.david.murray, 2016-09-10 00:36 review
issue27931_v2.patch xiang.zhang, 2016-09-10 05:44 review
Pull Requests
URL Status Linked Edit
PR 5329 merged jayyin11043, 2018-01-26 01:51
PR 5431 merged miss-islington, 2018-01-29 18:08
Messages (13)
msg274140 - (view) Author: Константин Волков (Константин Волков) Date: 2016-09-01 15:29
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.
msg274207 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-09-02 07:45
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 issue27931.patch to fix this.
msg274245 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-09-02 14:55
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.
msg274260 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-09-02 17:10
It should be. If there is anything wrong I'd like to hear and fix.
msg275238 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-09-09 02:41
Ping this and hope you don't forget about it David. :)
msg275513 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-09-10 00:36
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.
msg275572 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-09-10 05:44
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'
msg278839 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-10-18 03:18
Ping.
msg285042 - (view) Author: Константин Волков (Константин Волков) Date: 2017-01-09 13:40
ping
msg307328 - (view) Author: Константин Волков (Константин Волков) Date: 2017-11-30 16:41
ping
msg310761 - (view) Author: Jay Yin (jayyin11043) * Date: 2018-01-26 14:13
https://github.com/python/cpython/pull/5329
this is the pending pull request for this
msg311154 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2018-01-29 18:07
New changeset aa218d1649690d1c1ba86a9972f7fae646bf1a8f by R. David Murray (jayyyin) in branch 'master':
bpo-27931: Fix email address header parsing error (#5329)
https://github.com/python/cpython/commit/aa218d1649690d1c1ba86a9972f7fae646bf1a8f
msg311187 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2018-01-29 22:28
New changeset 6ea75b174da0cf824e2acc5db6b53798f5f4e4f9 by Mariatta (Miss Islington (bot)) in branch '3.6':
bpo-27931: Fix email address header parsing error (GH-5329) (GH-5431)
https://github.com/python/cpython/commit/6ea75b174da0cf824e2acc5db6b53798f5f4e4f9
History
Date User Action Args
2018-01-30 01:10:30xiang.zhangsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-01-29 22:28:04Mariattasetnosy: + Mariatta
messages: + msg311187
2018-01-29 18:08:04miss-islingtonsetpull_requests: + pull_request5266
2018-01-29 18:07:47r.david.murraysetmessages: + msg311154
2018-01-26 14:13:42jayyin11043setnosy: + jayyin11043
messages: + msg310761
2018-01-26 03:18:49xiang.zhangsettype: behavior
versions: + Python 3.7, - Python 3.5
2018-01-26 01:51:02jayyin11043setstage: commit review -> patch review
pull_requests: + pull_request5174
2017-11-30 16:41:51Константин Волковsetmessages: + msg307328
2017-01-09 13:40:51Константин Волковsetmessages: + msg285042
2016-10-18 03:18:00xiang.zhangsetmessages: + msg278839
2016-09-10 05:44:20xiang.zhangsetfiles: + issue27931_v2.patch

messages: + msg275572
2016-09-10 00:36:58r.david.murraysetfiles: + issue27931.patch

messages: + msg275513
2016-09-09 02:41:22xiang.zhangsetmessages: + msg275238
2016-09-02 17:10:11xiang.zhangsetmessages: + msg274260
2016-09-02 14:55:02r.david.murraysetassignee: r.david.murray
messages: + msg274245
stage: needs patch -> commit review
2016-09-02 07:45:15xiang.zhangsetfiles: + issue27931.patch

nosy: + xiang.zhang
messages: + msg274207

keywords: + patch
2016-09-01 15:41:03r.david.murraysetstage: needs patch
versions: + Python 3.6
2016-09-01 15:29:39Константин Волковcreate