classification
Title: Header folder folds incorrectly causing MissingHeaderBodySeparatorDefect
Type: behavior Stage:
Components: email Versions: Python 3.6, Python 3.4, Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: barry, r.david.murray, vincenttc
Priority: normal Keywords:

Created on 2016-09-23 21:22 by vincenttc, last changed 2016-09-23 21:48 by r.david.murray.

Messages (2)
msg277299 - (view) Author: Vincent Vanlaer (vincenttc) Date: 2016-09-23 21:22
Example:

X-Report-Abuse:
 =?us-ascii?q?=3Chttps=3A=2F=2Fwww=2Emailitapp=2Ecom=2Freport=5Fabuse=2Ephp=3Fmid=3Dxxx-xxx-xxxx?=
 =?us-ascii?q?xxxxxxxxxxxxxxxxxxxx=3D=3D-xxx-xx-xx=3E?=

When this header is parsed and reencoded as bytes using policy.default, the result is this:

X-Report-Abuse: <https://www.mailitapp.com/report_abuse.php?mid=xxx-xxx-xxxx
xxxxxxxxxxxxxxxxxxxx==-xxx-xx-xx>

Since the header does not require its value to be an encoded word, it is written as plain text. This removes the FWS between the encoded words. However, it appears that it is still seen as a, now invalid, folding point. When an email with this header is parsed again, it causes a MissingHeaderBodySeparatorDefect
msg277302 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-09-23 21:48
It seems to me this has been reported before, but I couldn't lay hands on the issue in a quick search.  With this description of the problem and example, I think I see what is wrong.  The folding algorithm is probably trying to handle the encoded words one by one instead of joining the ascii-only runs together first.

I'll try to take a look at this this weekend.
History
Date User Action Args
2016-09-23 21:48:42r.david.murraysetmessages: + msg277302
2016-09-23 21:22:55vincenttccreate