Skip to content

gh-78206: Limit encoded email body lines to 76 characters - #161645

Open
xixi-box wants to merge 4 commits into
python:mainfrom
xixi-box:fix/issue-78206-c07d1f4-7fe363f8
Open

xixi-box wants to merge 4 commits into
python:mainfrom
xixi-box:fix/issue-78206-c07d1f4-7fe363f8

Conversation

@xixi-box

@xixi-box xixi-box commented Nov 9, 2026 •

Copy link
Copy Markdown

Fixes #78206

Verified by running the failing test at c07d1f4f32ed (fails) and again with this patch applied (passes).

Signed-off-by: wangshun <96341168+xixi-box@users.noreply.github.com>
@xixi-box
xixi-box requested a review from a team as a code owner November 9, 2026 00:56
@bedevere-app

bedevere-app Bot commented Nov 9, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@xixi-box xixi-box changed the title fix: SMTP EmailPolicy not using the correct line length for RCF 2045 encoded data (is 78, should be 76) gh-78206: Limit encoded email body lines to 76 characters Nov 20, 2026

@vasiliyk vasiliyk 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.

The PR description mentions a failing test, but the diff does not include one.
Could you add a regression test to Lib/test/test_email/test_contentmanager.py?

Comment thread Lib/email/contentmanager.py Outdated

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.

Here we still pass max_line_length uncapped, so bytes content (attachments) is not covered.
Could we apply the cap here as well?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for pointing out the attachment path. I've capped base64 wrapping for bytes content at 76 columns, while preserving the policy's zero-length (unlimited) setting. I also added regression tests for text (base64 and quoted-printable) and byte attachments (bytes, bytearray, memoryview) with 60/78/100-column policies, including an unlimited-policy check. The changes are in a2a6447; I couldn't run the full CPython tests locally without a matching build, so CI validation is pending.

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.

SMTP EmailPolicy not using the correct line length for RCF 2045 encoded data (is 78, should be 76)

2 participants