The Wayback Machine - https://web.archive.org/web/20230627232625/https://github.com/python/cpython/issues/91400
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

email.utils.formataddr does not respect double spaces #91400

Open
AlecRosenbaum mannequin opened this issue Apr 6, 2022 · 1 comment
Open

email.utils.formataddr does not respect double spaces #91400

AlecRosenbaum mannequin opened this issue Apr 6, 2022 · 1 comment
Assignees
Labels
3.11 bug and security fixes topic-email type-bug An unexpected behavior, bug, or error

Comments

@AlecRosenbaum
Copy link
Mannequin

AlecRosenbaum mannequin commented Apr 6, 2022

BPO 47244
Nosy @warsaw, @bitdancer, @AlecRosenbaum

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2022-04-06.17:45:12.930>
labels = ['type-bug', '3.8', 'expert-email', '3.10', '3.11', '3.7', '3.9']
title = 'email.utils.formataddr does not respect double spaces'
updated_at = <Date 2022-04-06.17:45:12.930>
user = 'https://github.com/AlecRosenbaum'

bugs.python.org fields:

activity = <Date 2022-04-06.17:45:12.930>
actor = 'AlecRosenbaum'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['email']
creation = <Date 2022-04-06.17:45:12.930>
creator = 'AlecRosenbaum'
dependencies = []
files = []
hgrepos = []
issue_num = 47244
keywords = []
message_count = 1.0
messages = ['416891']
nosy_count = 3.0
nosy_names = ['barry', 'r.david.murray', 'AlecRosenbaum']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue47244'
versions = ['Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10', 'Python 3.11']

Linked PRs

@AlecRosenbaum
Copy link
Mannequin Author

AlecRosenbaum mannequin commented Apr 6, 2022

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" <[email protected]>'

print(formataddr(parseaddr(identity)))
# 'foo  bar <[email protected]>'

print(formataddr(parseaddr(formataddr(parseaddr(identity)))))
# 'foo bar <[email protected]>'

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.

@AlecRosenbaum AlecRosenbaum mannequin added 3.7 only security fixes 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes 3.11 bug and security fixes topic-email type-bug An unexpected behavior, bug, or error labels Apr 6, 2022
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@terryjreedy terryjreedy removed 3.8 only security fixes 3.7 only security fixes labels Apr 15, 2022
carlbordum added a commit to carlbordum/cpython that referenced this issue May 10, 2022
@gpshead gpshead self-assigned this Mar 17, 2023
@gpshead gpshead removed the 3.9 only security fixes label Mar 17, 2023
@hugovk hugovk removed the 3.10 only security fixes label Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 bug and security fixes topic-email type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants