]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
_split_ascii(): In the clause where curlen + partlen > maxlen, if the
authorBarry Warsaw <barry@python.org>
Thu, 6 Mar 2003 20:33:04 +0000 (20:33 +0000)
committerBarry Warsaw <barry@python.org>
Thu, 6 Mar 2003 20:33:04 +0000 (20:33 +0000)
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.

Lib/email/Header.py

index 47a5508ff27571f542036aa1d7e6abb265e9ad62..83fe0d5dbdb79e6cf01f5f1b1648c33731a2d84c 100644 (file)
@@ -456,7 +456,14 @@ def _split_ascii(s, firstlen, restlen, continuation_ws, splitchars):
             elif curlen + partlen > maxlen:
                 if this:
                     lines.append(joiner.join(this) + eol)
-                this = [part]
+                # If this part is longer than maxlen and we aren't already
+                # splitting on whitespace, try to recursively split this line
+                # on whitespace.
+                if partlen > maxlen and ch <> ' ':
+                    this = [_split_ascii(part, maxlen, restlen,
+                                         continuation_ws, ' ')]
+                else:
+                    this = [part]
                 linelen = wslen + partlen
                 maxlen = restlen
             else: