This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jribbens
Recipients jribbens
Date 2017-04-10.17:41:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1491846086.02.0.299208621231.issue30032@psf.upfronthosting.co.za>
In-reply-to
Content
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 ;-)
History
Date User Action Args
2017-04-10 17:41:26jribbenssetrecipients: + jribbens
2017-04-10 17:41:26jribbenssetmessageid: <1491846086.02.0.299208621231.issue30032@psf.upfronthosting.co.za>
2017-04-10 17:41:25jribbenslinkissue30032 messages
2017-04-10 17:41:25jribbenscreate