[New-bugs-announce] [issue27257] get_addresses results in traceback with a valid? header
Hans-Peter Jansen
report at bugs.python.org
Tue Jun 7 15:24:53 EDT 2016
New submission from Hans-Peter Jansen:
In the course of replacing an old Python 2.7 email filter tool with a rewritten Python3 version, I stumbled across a ugly case, where such an header:
To: unlisted-recipients: ;,
""@pop.kundenserver.de (no To-header on input)
results in a Traceback (most recent call last):
File "./mail_filter.py", line 606, in <module>
ret = main.run()
File "./mail_filter.py", line 595, in run
self.process(fp)
File "./mail_filter.py", line 520, in process
config.recipients = self.get_addresses('to', msg)
File "./mail_filter.py", line 103, in get_addresses
vals = msg.get_all(field, [])
File "/usr/lib64/python3.4/email/message.py", line 511, in get_all
values.append(self.policy.header_fetch_parse(k, v))
File "/usr/lib64/python3.4/email/policy.py", line 145, in header_fetch_parse
return self.header_factory(name, ''.join(value.splitlines()))
File "/usr/lib64/python3.4/email/headerregistry.py", line 584, in __call__
return self[name](name, value)
File "/usr/lib64/python3.4/email/headerregistry.py", line 195, in __new__
cls.parse(value, kwds)
File "/usr/lib64/python3.4/email/headerregistry.py", line 342, in parse
for mb in addr.all_mailboxes]))
File "/usr/lib64/python3.4/email/headerregistry.py", line 342, in <listcomp>
for mb in addr.all_mailboxes]))
File "/usr/lib64/python3.4/email/_header_value_parser.py", line 837, in local_part
return self[0].local_part
File "/usr/lib64/python3.4/email/_header_value_parser.py", line 889, in local_part
return self[0].local_part
File "/usr/lib64/python3.4/email/_header_value_parser.py", line 984, in local_part
tok[0].token_type == 'cfws'):
IndexError: list index out of range
I'm not completely sure, if the Top header, as added from my email provider, is perfectly valid, but none of the other parts of my mail infrastructure neither complained, nor behave strange with such headers.
This happens with 3.4.4, but also with the email module from current hg for testing.
----------
components: email
files: lkml-exception.mail
messages: 267733
nosy: barry, frispete, r.david.murray
priority: normal
severity: normal
status: open
title: get_addresses results in traceback with a valid? header
versions: Python 3.4, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file43287/lkml-exception.mail
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27257>
_______________________________________
More information about the New-bugs-announce
mailing list