Author frispete
Recipients barry, frispete, r.david.murray
Date 2016-06-07.19:24:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1465327493.81.0.354921385455.issue27257@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-06-07 19:24:55frispetesetrecipients: + frispete, barry, r.david.murray
2016-06-07 19:24:53frispetesetmessageid: <1465327493.81.0.354921385455.issue27257@psf.upfronthosting.co.za>
2016-06-07 19:24:53frispetelinkissue27257 messages
2016-06-07 19:24:53frispetecreate