classification
Title: generated email message exceeds RFC-mandated limit of 998 characters
Type: behavior Stage: resolved
Components: email Versions: Python 3.9, Python 3.8
process
Status: open Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: barry, ivyl, miss-islington, r.david.murray
Priority: normal Keywords: patch

Created on 2020-05-11 19:00 by ivyl, last changed 2020-05-18 00:58 by r.david.murray.

Pull Requests
URL Status Linked Edit
PR 20038 merged ivyl, 2020-05-11 19:10
PR 20084 merged miss-islington, 2020-05-14 00:53
Messages (5)
msg368641 - (view) Author: Arkadiusz Hiler (ivyl) * Date: 2020-05-11 19:00
RFC5322[0] in section 2.1.1 mandates that the line cannot be longer than 998 characters and should not be longer than 78 characters (excluding CRLF). When we use raw_data_manager (default for EmailPolicy, EmailMessage) it does the correct thing as long as the message contains characters outside of 7bit US-ASCII set - base64 or qp Content-Transfer-Encoding which respects the line wrapping at 78 characters.

However if our message is limited the characters from the 7bit US-ASCII set no transfer encoding is applied, and such messages can easily go beyond 78 or even 998 characters.


[0]: https://tools.ietf.org/html/rfc5322.html#section-2.1.1
msg368646 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2020-05-11 20:43
The PR looks good to me, but I describe the change differently.  I'm not sure how I missed this in the original implementation, since I obviously checked it for the 8bit case.  Too long ago to remember :)
msg368810 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2020-05-14 00:53
New changeset 6f2f475d5a2cd7675dce844f3af436ba919ef92b by Arkadiusz Hiler in branch 'master':
bpo-40597: email: Use CTE if lines are longer than max_line_length consistently (gh-20038)
https://github.com/python/cpython/commit/6f2f475d5a2cd7675dce844f3af436ba919ef92b
msg368811 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2020-05-14 00:57
Thanks, Arkadiusz.
msg369157 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2020-05-18 00:57
New changeset c1f1ddf30a595c2bfa3c06e54fb03fa212cd28b5 by Miss Islington (bot) in branch '3.8':
bpo-40597: email: Use CTE if lines are longer than max_line_length consistently (gh-20038) (gh-20084)
https://github.com/python/cpython/commit/c1f1ddf30a595c2bfa3c06e54fb03fa212cd28b5
History
Date User Action Args
2020-05-18 00:58:21r.david.murraysetstage: backport needed -> resolved
2020-05-18 00:57:49r.david.murraysetmessages: + msg369157
2020-05-14 00:57:34r.david.murraysetresolution: fixed
stage: patch review -> backport needed
messages: + msg368811
versions: - Python 3.5, Python 3.6, Python 3.7
2020-05-14 00:53:40miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request19388
2020-05-14 00:53:34r.david.murraysetmessages: + msg368810
2020-05-11 20:43:39r.david.murraysetmessages: + msg368646
2020-05-11 19:10:54ivylsetkeywords: + patch
stage: patch review
pull_requests: + pull_request19348
2020-05-11 19:00:19ivylcreate