Issue 47244: email.utils.formataddr does not respect double spaces - Python tracker
Python Home About News Documentation Downloads Community Foundation Developer's Guide Issue Tracker Issues Search Random Issue Summaries Issues with patch Easy issues Stats User Administration User List Committer List Help Tracker Documentation Tracker Development Report Tracker Problem Issue47244 ➜ 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.
Created on 2022-04-06 17:45 by AlecRosenbaum , last changed 2022-04-11 14:59 by admin . Messages (1) msg416891 - (view) Author: Alec Rosenbaum (AlecRosenbaum) Date: 2022-04-06 17:45 It seems that `email.utils.formataddr` and `email.utils.parseaddr` are not directly inverse from each other, because `formataddr` does not respect double spaces within the "realname" section. For example: ``` from email.utils import formataddr, parseaddr identity = '"foo bar" < foo@example.com >' print(formataddr(parseaddr(identity))) # 'foo bar < foo@example.com >' print(formataddr(parseaddr(formataddr(parseaddr(identity))))) # 'foo bar < foo@example.com >' ``` The first round trip strips the quotes, and the second round trip strips the double space in the "realname" section.
The utility function only seems to check for special characters, but it should also check for double spaces. History Date User Action Args 2022-04-11 14:59:58 admin set github: 91400 2022-04-06 17:45:12 AlecRosenbaum create Supported by The Python Software Foundation , Powered by Roundup Copyright © 1990-2022, Python Software Foundation Legal Statements