Skip to content

gh-133311: have MIMEImage respect policy.max_line_length #133322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bpo-133311: have MIMEImage respect policy.max_line_length
This patch updates Lib/email/mime/image.py so that MIMEImage honors the max_line_length
setting from the provided EmailPolicy when Base64-encoding image payloads.

- Adds imports for base64 and textwrap.wrap
- Replaces the old `self.set_payload(_imagedata)` + `_encoder(self)` calls
  with an explicit Base64 encode, wrap to `policy.max_line_length` (default 76),
  and then calls `self.set_payload` with the wrapped text.
- Ensures CRLF line endings and proper headers are still applied by set_payload.
  • Loading branch information
vedant713 authored May 2, 2025
commit d309c31d4c1e20f106c02f2ca45c6ff4dfd50f4c

No changes to show.

This commit has no content.