[issue32058] Faulty behaviour in email.utils.parseaddr if square brackets in subject

2017-11-17 Thread R. David Murray
R. David Murray added the comment: Unfortunately the imap module in the stdlib doesn't provide a whole lot in the way of tools for parsing the imap data, just for sending it back and forth to the server. -- ___ Python

[issue32058] Faulty behaviour in email.utils.parseaddr if square brackets in subject

2017-11-17 Thread tom de wulf
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 (" +

[issue32058] Faulty behaviour in email.utils.parseaddr if square brackets in subject

2017-11-17 Thread R. David Murray
R. David Murray added the comment: parseaddr is for parsing the contents of an address header, not for parsing any additional text. So the correct way to call it is parseaddress('someone '). In any case, please look in to the new email policies,

[issue32058] Faulty behaviour in email.utils.parseaddr if square brackets in subject

2017-11-17 Thread tom de wulf
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') >>>