[issue32058] Faulty behaviour in email.utils.parseaddr if square brackets in subject
tom de wulf 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 <https://bugs.python.org/issue32058> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue32058] Faulty behaviour in email.utils.parseaddr if square brackets in subject
New submission from tom de wulf : Probably a parsing bug in email.utils.parseaddr. How to recreate: >>> import email.utils >>> test = 'Subject: I am a bug [Random]\r\nFrom: someone >>> \r\n\r\n' >>> email.utils.parseaddr(test) ('', 'I') >>> email.utils.parseaddr(test.replace('[', '').replace(']','')) ('someone', 'some@email.address') Expected behaviour: no need to remove the []'s -- components: email messages: 306431 nosy: barry, r.david.murray, tom de wulf priority: normal severity: normal status: open title: Faulty behaviour in email.utils.parseaddr if square brackets in subject type: behavior versions: Python 3.5 ___ Python tracker <https://bugs.python.org/issue32058> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com