R. David Murray <rdmur...@bitdance.com> added the comment:

Parsing and newlines have nothing to do with this bug, actually.  I don't think 
your foldfix post-processing is going to do what you want in the general case.

The source of the bug here is in the folding algorithm in _header_value_parser. 
 It has checks to see if the "text so far" will fit within the header width, 
and it starts a new line under vafious conditions.  For example, if there is a 
single word after Subject: whose length is, say, 70, it would produce the 
effect you show, because the single word would fit without folding or encoding 
on a new line.  I don't think this violates the RFC.  What your example shows 
makes it look like the folder is treating all of the text as if it were a 
single word, which is obviously wrong.  It is supposed to break at spaces.  You 
will note that if you increase the repeat count in your example to 16 it folds 
the line correctly.  So the bug has something to do with the total text so far 
accumulated for the line being right in that window where it won't fit on the 
first line but does fit on a line by itself.  This is obviously a bug in the 
folder, since it should be splitting that text if it isn't a sin
 gle word, not moving it to a new line as a whole.

Note that this bug is still present on master.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43493>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to