summaryrefslogtreecommitdiffstats
path: root/Lib/email/contentmanager.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2016-09-09 19:00:09 (GMT)
committerR David Murray <rdmurray@bitdance.com>2016-09-09 19:00:09 (GMT)
commit94a7927cc6ad7c2fa986cc207f1f655eb017fa18 (patch)
tree83f61a38801af0735f31454c04190c1b5a451e14 /Lib/email/contentmanager.py
parentde02b084e6e5c57be32414da87111679a89049f7 (diff)
downloadcpython-94a7927cc6ad7c2fa986cc207f1f655eb017fa18.zip
cpython-94a7927cc6ad7c2fa986cc207f1f655eb017fa18.tar.gz
cpython-94a7927cc6ad7c2fa986cc207f1f655eb017fa18.tar.bz2
#28047: Fix calculation of base64 line length.
This is buggy in the old email code as well, but it doesn't affect anything there because only the default line length is ever used there.
Diffstat (limited to 'Lib/email/contentmanager.py')
-rw-r--r--Lib/email/contentmanager.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/email/contentmanager.py b/Lib/email/contentmanager.py
index d363652..b98ce27 100644
--- a/Lib/email/contentmanager.py
+++ b/Lib/email/contentmanager.py
@@ -126,12 +126,13 @@ def _finalize_set(msg, disposition, filename, cid, params):
msg.set_param(key, value)
-# XXX: This is a cleaned-up version of base64mime.body_encode. It would
-# be nice to drop both this and quoprimime.body_encode in favor of
-# enhanced binascii routines that accepted a max_line_length parameter.
+# XXX: This is a cleaned-up version of base64mime.body_encode (including a bug
+# fix in the calculation of unencoded_bytes_per_line). It would be nice to
+# drop both this and quoprimime.body_encode in favor of enhanced binascii
+# routines that accepted a max_line_length parameter.
def _encode_base64(data, max_line_length):
encoded_lines = []
- unencoded_bytes_per_line = max_line_length * 3 // 4
+ unencoded_bytes_per_line = max_line_length // 4 * 3
for i in range(0, len(data), unencoded_bytes_per_line):
thisline = data[i:i+unencoded_bytes_per_line]
encoded_lines.append(binascii.b2a_base64(thisline).decode('ascii'))