[issue43493] EmailMessage mis-folding headers of a certain length

R. David Murray report at bugs.python.org
Tue Jul 6 13:16:58 EDT 2021


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

Ah, yes, the problem is more subtle than I thought.

The design here is that we should be starting with the largest lexical unit, seeing if that fits on the current line, or a line by itself, and if so, using that, and if not, move down to the next smaller lexical unit and try again, until we are finally left with an unbreakable unit.  For unstructured headers such as Subject the lexical units should be encoded words followed by blank delimited words.  I'm guessing the code is treating the collection of words it has accumulated as a unit in the above algorithm, and since it fits on a line by itself, it goes with that.  So yeah, it's sort of intentional.

So the bug here is that in your step 2 we ideally want to be considering whether the last token on the current line is at the same lexical level as the token that precedes it...and if so, and if moving that token to the next line lets the remainder fit on the first line, we should do that.  Exactly how to implement that correctly is a good question...it's been too long since I wrote that code, and I may not have time to investigate it more deeply.

If you come up with something based on my description of the intent above, I should be able to review it (though you might need to ping me directly to get my attention).

----------

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


More information about the Python-bugs-list mailing list