Skip to content

gh-162125: Preserve parentheses when folding email comments - #162163

Open
Burnside999 wants to merge 1 commit into
python:mainfrom
Burnside999:fix/gh-162125-email-comments
Open

Burnside999 wants to merge 1 commit into
python:mainfrom
Burnside999:fix/gh-162125-email-comments

Conversation

@Burnside999

@Burnside999 Burnside999 commented Nov 17, 2026 •

Copy link
Copy Markdown

This addresses the loss of comment parentheses reported in #162125. Folding Ana (ñ) <a@example.com> could turn the comment into part of the display name. The folded header now retains the parentheses, preserving the address semantics when parsed again.

Handle comments at their actual token boundaries, keep delimiters outside encoded words, and prevent encoded-word merging across comments. Add reproducible generated round-trip tests for Unicode comments, quoted pairs, and display names, with fixed regressions for nested comments and folding limits.

Keep comment delimiters outside encoded words and stop encoded-word
merging at actual comment boundaries.

Add reproducible generated round-trip tests for Unicode comments,
quoted pairs, display names, and folding limits.
@Burnside999
Burnside999 requested a review from a team as a code owner November 17, 2026 17:50
@python-cla-bot

python-cla-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@Burnside999

Copy link
Copy Markdown
Author

This PR currently fixes the comment-parenthesis loss in _refold_with_ew(). The trailing-comment HeaderWriteError cases reported in #162125 go through _refold_without_ew(). Would it make sense to investigate those cases in this PR as well, or would a separate PR be preferable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant