Commit 9b8d3df
authored
mime: 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 `set_payload(_imagedata)` + `_encoder(self)` calls
with an explicit Base64 encode, wrap to `policy.max_line_length` (default 76),
and then calls `set_payload` with the wrapped text.
- Ensures CRLF line endings and proper headers are still applied by set_payload.
Fixes issue #133311: MIMEImage’s policy argument not taking effect.1 parent 49ea8a0 commit 9b8d3df
1 file changed
+15
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
42 | | - | |
43 | | - | |
44 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
45 | 57 | | |
46 | 58 | | |
47 | 59 | | |
| |||
0 commit comments