Skip to content

gh-87720 Fix additional header refolding-quoting edge case - #134271

Merged
bitdancer merged 5 commits into
python:mainfrom
bitdancer:another_refolding_edge_case
Oct 9, 2026
Merged

bitdancer merged 5 commits into
python:mainfrom
bitdancer:another_refolding_edge_case

Conversation

@bitdancer

@bitdancer bitdancer commented May 19, 2025 •

Copy link
Copy Markdown
Member

In this case, the higher level syntactic unit fit on the remainder of the line in un-encoded format, so the encoding check never happened. To fix this, we look inside the current unit to see if has anything that was originally encoded.

I'm not really happy with the method name 'has_token_type', but I haven't thought of anything I like better. Ideas welcome.

In this case, the higher level syntactic unit fit on the remainder of
the line in un-encoded format, so the encoding check never happened.  To
fix this, we look inside the current unit to see if has anything that
was originally encoded.
@bitdancer

Copy link
Copy Markdown
Member Author

@medmunds Do you feel like reviewing this? :)

@medmunds

Copy link
Copy Markdown
Contributor

I'm not really happy with the method name 'has_token_type', but I haven't thought of anything I like better. Ideas welcome.

contains_token_type? (Though I'm not convinced that's any better; has_token_type makes sense to me too.)

@medmunds medmunds left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix LGTM. But I found another corner case while looking at it. Here's the failing test:

--- a/Lib/test/test_email/test__header_value_parser.py	(revision ebde4e897750963b82bcae785949ac11b3877640)
+++ b/Lib/test/test_email/test__header_value_parser.py	(date 1748289921461)
@@ -3101,6 +3101,8 @@
              '=?utf-8?q?a=2C?=\n'
              ' 123456789012345678901234567890123456\n'
              ' <abc@example.com>\n'),
+            ('abc@example.com (, but definitely not also sent to def@example.net)',
+             'abc@example.com (, but definitely not\n also sent to def@example.net)\n'),
         ]
         for (to, folded) in cases:
             with self.subTest(to=to):

(This case belongs in a new test covering comment folding, but you'll get the point. Guessing I should open a new issue—it's more like the earlier quoted-string problem. I bring it up here in case it might help you spot other xtext variations needing attention.)

(Also, is this on Seth's radar yet?)

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 24, 2026

@medmunds medmunds left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still looks good.

This probably should get security backports.

@bitdancer
bitdancer merged commit 5a22a62 into python:main Oct 9, 2026
55 checks passed
@bitdancer bitdancer added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Oct 9, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @bitdancer for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @bitdancer for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @bitdancer for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @bitdancer for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @bitdancer for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Oct 9, 2026

Copy link
Copy Markdown

GH-159065 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.11 only security fixes label Oct 9, 2026
@bedevere-app

bedevere-app Bot commented Oct 9, 2026

Copy link
Copy Markdown

GH-159066 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Oct 9, 2026
@bedevere-app

bedevere-app Bot commented Oct 9, 2026

Copy link
Copy Markdown

GH-159067 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 9, 2026
@bedevere-app

bedevere-app Bot commented Oct 9, 2026

Copy link
Copy Markdown

GH-159068 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Oct 9, 2026
@bedevere-app

bedevere-app Bot commented Oct 9, 2026

Copy link
Copy Markdown

GH-159069 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Oct 9, 2026
bitdancer added a commit that referenced this pull request Oct 9, 2026
…-134271) (#159067)

In this case, the higher level syntactic unit fit on the remainder of
the line in un-encoded format, and that higher level unit was
not a ptext or vtext, so the encoding check failed.  To fix this, we
look inside the current unit to see if has anything that was
originally encoded.
(cherry picked from commit 5a22a62)

Co-authored-by: R. David Murray <rdmurray@bitdance.com>
@medmunds

medmunds commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #87720.

bitdancer added a commit that referenced this pull request Oct 9, 2026
…-134271) (#159069)

In this case, the higher level syntactic unit fit on the remainder of
the line in un-encoded format, and that higher level unit was
not a ptext or vtext, so the encoding check failed.  To fix this, we
look inside the current unit to see if has anything that was
originally encoded.
(cherry picked from commit 5a22a62)

Co-authored-by: R. David Murray <rdmurray@bitdance.com>
@bitdancer
bitdancer deleted the another_refolding_edge_case branch October 9, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants