summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2003-03-06 20:33:04 (GMT)
committerBarry Warsaw <barry@python.org>2003-03-06 20:33:04 (GMT)
commitbd836dfba3fd0d86807196c4049e998a4b9b9b92 (patch)
tree193934581ff3fc33e65440b1a45e23af72f21d2a /Lib/email
parentf0d35856691bcee72f64e028959ee8f602fbff08 (diff)
downloadcpython-bd836dfba3fd0d86807196c4049e998a4b9b9b92.zip
cpython-bd836dfba3fd0d86807196c4049e998a4b9b9b92.tar.gz
cpython-bd836dfba3fd0d86807196c4049e998a4b9b9b92.tar.bz2
_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.
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/Header.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/email/Header.py b/Lib/email/Header.py
index 47a5508..83fe0d5 100644
--- a/Lib/email/Header.py
+++ b/Lib/email/Header.py
@@ -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: