GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [3.13] gh-121650: Encode newlines in headers, and verify headers are sound (GH-122233) by miss-islington · Pull Request #122484 · python/cpython

Conversation

@miss-islington

@miss-islington miss-islington commented Jul 30, 2024 •
edited by encukou
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Encode header parts that contain newlines

Per RFC 2047:

[...] these encoding schemes allow the
encoding of arbitrary octet values, mail readers that implement this
decoding should also ensure that display of the decoded data on the
recipient's terminal will not cause unwanted side-effects

It seems that the "quoted-word" scheme is a valid way to include
a newline character in a header value, just like we already allow
undecodable bytes or control characters.
They do need to be properly quoted when serialized to text, though.

  • Verify that email headers are well-formed

This should fail for custom fold() implementations that aren't careful
about newlines.

(cherry picked from commit 0976339)

Co-authored-by: Petr Viktorin [email protected]
Co-authored-by: Bas Bloemsaat [email protected]
Co-authored-by: Serhiy Storchaka [email protected]

  • Issue: email.policy.default - gotcha with re-using parsed headers with embedded newlines #121650

📚 Documentation preview 📚: https://cpython-previews--122484.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@encukou @basbloemsaat
@serhiy-storchaka @miss-islington
pythongh-121650: Encode newlines in headers, and verify headers are s…
a590277
…ound (pythonGH-122233)

GH-GH- Encode header parts that contain newlines

Per RFC 2047:

> [...] these encoding schemes allow the
> encoding of arbitrary octet values, mail readers that implement this
> decoding should also ensure that display of the decoded data on the
> recipient's terminal will not cause unwanted side-effects

It seems that the "quoted-word" scheme is a valid way to include
a newline character in a header value, just like we already allow
undecodable bytes or control characters.
They do need to be properly quoted when serialized to text, though.

GH-GH- Verify that email headers are well-formed

This should fail for custom fold() implementations that aren't careful
about newlines.

(cherry picked from commit 0976339)

Co-authored-by: Petr Viktorin <[email protected]>
Co-authored-by: Bas Bloemsaat <[email protected]>
Co-authored-by: Serhiy Storchaka <[email protected]>
@miss-islington
miss-islington requested a review from a team as a code owner July 30, 2024 22:19
This was referenced Jul 30, 2024
email.policy.default - gotcha with re-using parsed headers with embedded newlines #121650
Closed
gh-121650: Encode newlines in headers, and verify headers are sound #122233
Merged
@bedevere-app bedevere-app Bot added the awaiting review label Jul 30, 2024
@encukou encukou added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jul 30, 2024
@bedevere-bot

bedevere-bot commented Jul 30, 2024

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @encukou for commit a590277 🤖

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jul 30, 2024
@encukou

encukou commented Aug 1, 2024

Copy link
Copy Markdown
Member

The buildbot failures are unrelated/pre-existing.

As this missed rc1, I'd like to ask for a review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ambv

ambv commented Aug 2, 2024

Copy link
Copy Markdown
Contributor

OK, then I'll wait with merging 3.11 - 3.8 until the review here is done.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@encukou
Merge branch '3.13' into backport-0976339-3.13
3c5a90f
@encukou encukou mentioned this pull request Aug 3, 2024
[3.12] gh-121650: Encode newlines in headers, and verify headers are sound (GH-122233) #122599
Merged
@Yhg1s
Yhg1s merged commit 4aaa425 into python:3.13 Aug 6, 2024
@bedevere-app bedevere-app Bot removed the awaiting review label Aug 6, 2024
@miss-islington
miss-islington deleted the backport-0976339-3.13 branch January 2, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@miss-islington @bedevere-bot @encukou @ambv @Yhg1s
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.