New submission from Alec Rosenbaum <a...@rosenbaum.io>:
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" <f...@example.com>' print(formataddr(parseaddr(identity))) # 'foo bar <f...@example.com>' print(formataddr(parseaddr(formataddr(parseaddr(identity))))) # 'foo bar <f...@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. ---------- components: email messages: 416891 nosy: AlecRosenbaum, barry, r.david.murray priority: normal severity: normal status: open title: email.utils.formataddr does not respect double spaces type: behavior versions: Python 3.10, Python 3.11, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue47244> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com