gh-100900: Quote non-ASCII display names containing specials in formataddr - #155881
Open
nikolauspschuetz wants to merge 1 commit into
Open
gh-100900: Quote non-ASCII display names containing specials in formataddr#155881nikolauspschuetz wants to merge 1 commit into
nikolauspschuetz wants to merge 1 commit into
Conversation
… formataddr
formataddr() quotes an ASCII display name that contains specials, but the
non-ASCII branch returned charset.header_encode(name) unquoted. When the
charset is configured not to RFC 2047-encode the name (e.g. after
add_charset('utf-8', None)), header_encode is a no-op, so specials such as a
comma were emitted bare and the header no longer round-tripped through
getaddresses(). Quote such a name the same way the ASCII branch does.
nikolauspschuetz
force-pushed
the
gh-100900-formataddr-nonascii-specials
branch
from
August 16, 2026 03:56
30ff05b to
67562c4
Compare
nikolauspschuetz
marked this pull request as ready for review
August 16, 2026 04:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
formataddrquotes an ASCII display name that contains specials (e.g. a comma in a"Last, First"name), but the non-ASCII branch returnedcharset.header_encode(name)unquoted. When the charset is configured not to RFC 2047-encode the name (e.g.add_charset('utf-8', None)),header_encodeis a no-op, so a comma in the name is emitted bare and the header parses back as two addresses throughgetaddresses.Quote the non-ASCII name when it still contains specials, mirroring the ASCII branch — default-charset output is unchanged, since a real RFC 2047 encoded word never contains specials. Adds a regression test.
Thanks to @tonghuaroot for confirming and pinpointing this on the issue.
Fixes #100900