This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author elenril
Recipients barry, elenril, r.david.murray
Date 2021-03-15.13:11:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1615813865.05.0.348558302999.issue43501@roundup.psfhosted.org>
In-reply-to
Content
On parsing an email where the display name in an address ends on a dot immediately followed by angle-addr, accessing the resulting mailbox display_name throws
/usr/lib/python3.9/email/_header_value_parser.py in value(self)
    589             if self[0].token_type=='cfws' or self[0][0].token_type=='cfws':
    590                 pre = ' '
--> 591             if self[-1].token_type=='cfws' or self[-1][-1].token_type=='cfws':
    592                 post = ' '
    593             return pre+quote_string(self.display_name)+post

AttributeError: 'str' object has no attribute 'token_type'

The problem is that self[-1] is the terminal DOT.

An example of the problematic header is:
From: foobar.<baz@spam>
History
Date User Action Args
2021-03-15 13:11:05elenrilsetrecipients: + elenril, barry, r.david.murray
2021-03-15 13:11:05elenrilsetmessageid: <1615813865.05.0.348558302999.issue43501@roundup.psfhosted.org>
2021-03-15 13:11:04elenrillinkissue43501 messages
2021-03-15 13:11:04elenrilcreate