[New-bugs-announce] [issue30032] email module creates base64 output with incorrect line breaks
Jon Ribbens
report at bugs.python.org
Mon Apr 10 13:41:26 EDT 2017
New submission from Jon Ribbens:
The email module, when creating base64-encoded text parts, does not process line breaks correctly - RFC 2045 s6.8 says that line breaks must be converted to CRLF before base64-encoding, and the email module is not doing this.
>>> from email.mime.text import MIMEText
>>> import base64
>>> m = MIMEText("hello\nthere", _charset="utf-8")
>>> m.as_string()
'Content-Type: text/plain; charset="utf-8"\nMIME-Version: 1.0\nContent-Transfer-Encoding: base64\n\naGVsbG8KdGhlcmU=\n'
>>> base64.b64decode("aGVsbG8KdGhlcmU=")
b'hello\nthere'
You might say that it is the application's job to convert the line endings before calling MIMEText(), but I think all application authors would be surprised by this. Certainly the MailMan authors would be, as they say this is a Python bug not a MailMan bug ;-)
----------
components: Library (Lib)
messages: 291434
nosy: jribbens
priority: normal
severity: normal
status: open
title: email module creates base64 output with incorrect line breaks
type: behavior
versions: Python 2.7, Python 3.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30032>
_______________________________________
More information about the New-bugs-announce
mailing list