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-92081: Fix for email.generator.Generator with whitespace between encoded words. (GH-92281) by miss-islington · Pull Request #119245 · python/cpython

Conversation

@miss-islington

@miss-islington miss-islington commented May 20, 2024

Copy link
Copy Markdown
Contributor
  • Fix for email.generator.Generator with whitespace between encoded words.

email.generator.Generator currently does not handle whitespace between
encoded words correctly when the encoded words span multiple lines. The
current generator will create an encoded word for each line. If the end
of the line happens to correspond with the end real word in the
plaintext, the generator will place an unencoded space at the start of
the subsequent lines to represent the whitespace between the plaintext
words.

A compliant decoder will strip all the whitespace from between two
encoded words which leads to missing spaces in the round-tripped
output.

The fix for this is to make sure that whitespace between two encoded
words ends up inside of one or the other of the encoded words. This
fix places the space inside of the second encoded word.

A second problem happens with continuation lines. A continuation line that
starts with whitespace and is followed by a non-encoded word is fine because
the newline between such continuation lines is defined as condensing to
a single space character. When the continuation line starts with whitespace
followed by an encoded word, however, the RFCs specify that the word is run
together with the encoded word on the previous line. This is because normal
words are filded on syntactic breaks by encoded words are not.

The solution to this is to add the whitespace to the start of the encoded word
on the continuation line.

Test cases are from GH-92081

  • Rename a variable so it's not confused with the final variable.
    (cherry picked from commit a6fdb31)

Co-authored-by: Toshio Kuratomi [email protected]

Sorry, something went wrong.

Uh oh!

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

All reactions
@abadger @miss-islington
pythongh-92081: Fix for email.generator.Generator with whitespace bet…
6f431e7
…ween encoded words. (pythonGH-92281)

* Fix for email.generator.Generator with whitespace between encoded words.

email.generator.Generator currently does not handle whitespace between
encoded words correctly when the encoded words span multiple lines.  The
current generator will create an encoded word for each line.  If the end
of the line happens to correspond with the end real word in the
plaintext, the generator will place an unencoded space at the start of
the subsequent lines to represent the whitespace between the plaintext
words.

A compliant decoder will strip all the whitespace from between two
encoded words which leads to missing spaces in the round-tripped
output.

The fix for this is to make sure that whitespace between two encoded
words ends up inside of one or the other of the encoded words.  This
fix places the space inside of the second encoded word.

A second problem happens with continuation lines.  A continuation line that
starts with whitespace and is followed by a non-encoded word is fine because
the newline between such continuation lines is defined as condensing to
a single space character.  When the continuation line starts with whitespace
followed by an encoded word, however, the RFCs specify that the word is run
together with the encoded word on the previous line.  This is because normal
words are filded on syntactic breaks by encoded words are not.

The solution to this is to add the whitespace to the start of the encoded word
on the continuation line.

Test cases are from pythonGH-92081

* Rename a variable so it's not confused with the final variable.
(cherry picked from commit a6fdb31)

Co-authored-by: Toshio Kuratomi <[email protected]>
@miss-islington
miss-islington requested a review from a team as a code owner May 20, 2024 19:10
@bedevere-app bedevere-app Bot added the awaiting review label May 20, 2024
This was referenced May 20, 2024
BytesGenerator breaks UTF8 string #92081
Closed
gh-92081: Fix for email.generator.Generator with whitespace between encoded words. #92281
Merged
@warsaw warsaw self-assigned this May 20, 2024
warsaw
warsaw approved these changes May 20, 2024
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels May 20, 2024
warsaw
warsaw approved these changes May 20, 2024
View reviewed changes
@warsaw
warsaw enabled auto-merge (squash) May 20, 2024 19:33
@warsaw
warsaw disabled auto-merge May 20, 2024 19:35
@warsaw
warsaw enabled auto-merge (squash) May 20, 2024 19:35
@warsaw
warsaw merged commit 054f1af into python:3.13 May 20, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label May 20, 2024
@JelleZijlstra JelleZijlstra mentioned this pull request May 28, 2024
backport a9a74da 3.13 #119642
Closed
@miss-islington
miss-islington deleted the backport-a6fdb31-3.13 branch January 2, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@warsaw warsaw warsaw approved these changes

Uh oh!

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

Assignees

@warsaw warsaw

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.

3 participants

@miss-islington @warsaw @abadger
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.