[issue35863] email.headers wraps headers badly

R. David Murray report at bugs.python.org
Thu Jan 31 21:30:34 EST 2019


R. David Murray <rdmurray at bitdance.com> added the comment:

The rules are: lines should be less than 78 characters; and that lines may be broken only at FWS (folding whitespace), not in the middle of words.  Putting these rules together, you get the result that the email library produces.  "Conservative in what you send" means *following the RFC rules*, which is what the code does.  The failure here is on the Outlook side, which is supposed to be being "liberal in what you accept".  Which it is clearly not doing.

In case you want to read the RFCs, which I just reviewed, Content-ID is defined to have the same syntax as Message-ID, and Message-Id is defined as "Message-ID:" msg-id CRLF, while 'msg-id' is defined as:

    msg-id          =       [CFWS] "<" id-left "@" id-right ">" [CFWS]

Which means that a fold is permitted before the id itself.

We could consider an "enhancement" request to cater to Outlook's deficiency, since email clients that are actually limited to 78 character lines are vanishingly rare these days.  The change would only be made in the new API folder, and I myself wouldn't have the time (or desire :) to work on it, but if you want to submit an issue as see what the other email team members think and produce a PR if the vote is positive, that's fine by me.

Do you know if it is all headers that Outlook has this problem with, or only some?  I will admit that it has been long enough since I implemented this that I can't confirm that I made sure it was legal to fold *every* header after the colon, but I'm pretty sure I did.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35863>
_______________________________________


More information about the Python-bugs-list mailing list