Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bd836df

Browse files
committed
_split_ascii(): In the clause where curlen + partlen > maxlen, if the
part itself is longer than maxlen, and we aren't already splitting on whitespace, then we recursively split the part on whitespace and append that to the this list.
1 parent f0d3585 commit bd836df

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Lib/email/Header.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,14 @@ def _split_ascii(s, firstlen, restlen, continuation_ws, splitchars):
456456
elif curlen + partlen > maxlen:
457457
if this:
458458
lines.append(joiner.join(this) + eol)
459-
this = [part]
459+
# If this part is longer than maxlen and we aren't already
460+
# splitting on whitespace, try to recursively split this line
461+
# on whitespace.
462+
if partlen > maxlen and ch <> ' ':
463+
this = [_split_ascii(part, maxlen, restlen,
464+
continuation_ws, ' ')]
465+
else:
466+
this = [part]
460467
linelen = wslen + partlen
461468
maxlen = restlen
462469
else:

0 commit comments

Comments
 (0)