[issue32058] Faulty behaviour in email.utils.parseaddr if square brackets in subject
tom de wulf
report at bugs.python.org
Fri Nov 17 09:12:07 EST 2017
tom de wulf <dewulfmail at gmail.com> added the comment:
I do get this data from an IMAP fetch statement, see my code below:
rv, data = imap.fetch(num, "(BODY[HEADER.FIELDS (FROM SUBJECT)])")
if rv != 'OK':
logging.error("Error getting message sender and subject (" + num.decode("ascii") + ")")
return
logging.info("Got message " + num.decode("ascii"))
sender_subject = data[0][1].decode("utf-8")
sender = email.utils.parseaddr(sender_subject.replace('[', '').replace(']',''))[1].replace("\r\n", "")
Thank you for providing this new API though, I will make sure to switch to that.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32058>
_______________________________________
More information about the Python-bugs-list
mailing list