Issue31445
Created on 2017-09-13 09:53 by Michala, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| _header_value_parser.py | Michala, 2017-10-09 13:01 | |||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 6825 | closed | radar383, 2018-05-14 19:47 | |
| PR 6828 | closed | bfrosik, 2018-05-14 20:06 | |
| Messages (5) | |||
|---|---|---|---|
| msg302043 - (view) | Author: (Michala) | Date: 2017-09-13 09:53 | |
This error occured when the email field "From" was demanded:
File "/home/user/processing/Test/process_email.py", line 84, in __init__
self.field_from_full = msg.get("From")
File "/usr/local/lib/python3.6/email/message.py", line 471, in get
return self.policy.header_fetch_parse(k, v)
File "/usr/local/lib/python3.6/email/policy.py", line 162, in header_fetch_parse
return self.header_factory(name, value)
File "/usr/local/lib/python3.6/email/headerregistry.py", line 586, in __call__
return self[name](name, value)
File "/usr/local/lib/python3.6/email/headerregistry.py", line 197, in __new__
cls.parse(value, kwds)
File "/usr/local/lib/python3.6/email/headerregistry.py", line 337, in parse
kwds['parse_tree'] = address_list = cls.value_parser(value)
File "/usr/local/lib/python3.6/email/headerregistry.py", line 328, in value_parser
address_list, value = parser.get_address_list(value)
File "/usr/local/lib/python3.6/email/_header_value_parser.py", line 2336, in get_address_list
token, value = get_address(value)
File "/usr/local/lib/python3.6/email/_header_value_parser.py", line 2313, in get_address
token, value = get_group(value)
File "/usr/local/lib/python3.6/email/_header_value_parser.py", line 2284, in get_group
if value[0] != ';':
IndexError: string index out of range
I used EmailPolicy, so the message object was instance of EmailMessage.
Header field "From" had following form:
"From: Bonifac Karaka : bonikar@gmail.com"
|
|||
| msg303948 - (view) | Author: (Michala) | Date: 2017-10-09 13:01 | |
I added 2 lines into the file "email/_header_value_parser.py"
into the function "get_mailbox_list(value)" before return value:
if not value:
value = ';'
return mailbox_list, value
It is in attachments.
|
|||
| msg316565 - (view) | Author: Randy Wong (radar383) * | Date: 2018-05-14 19:47 | |
Submitted pull request: fix-issue-31455: Changed by adding two lines in the module "email/_header_value_parser.py" into the function "get_mailbox_list(value)" before return mailbox_list, value to avoid IndexError. |
|||
| msg345629 - (view) | Author: Abhilash Raj (maxking) * ![]() |
Date: 2019-06-14 18:52 | |
I can't reproduce this issue on the latest master branch. This seems to be fixed as a part of a different PR I suppose.
>>> import email
>>> msg = email.message_from_string("From: Bonifac Karaka : bonikar@gmail.com")
>>> msg['From']
'Bonifac Karaka : bonikar@gmail.com'
This is very similar to bpo-32178, which also is now fixed.
@david, @barry, I think we can close this issue.
|
|||
| msg347589 - (view) | Author: R. David Murray (r.david.murray) * ![]() |
Date: 2019-07-10 01:08 | |
Note that the reporter indicated that the message was an instance of EmailMessage (the new API). You'd need to use policy-default to get that using message_from_string. But yes, this was fixed in another issue. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:52 | admin | set | github: 75626 |
| 2019-07-10 01:08:34 | r.david.murray | set | status: open -> closed messages:
+ msg347589 |
| 2019-06-14 18:52:51 | maxking | set | nosy:
+ maxking messages: + msg345629 |
| 2018-05-14 20:06:14 | bfrosik | set | pull_requests: + pull_request6512 |
| 2018-05-14 19:47:22 | radar383 | set | nosy:
+ radar383 messages: + msg316565 pull_requests: + pull_request6510 keywords:
+ patch |
| 2017-10-09 13:01:34 | Michala | set | files:
+ _header_value_parser.py resolution: works for me messages: + msg303948 |
| 2017-09-13 09:53:21 | Michala | create | |
