Set maxlen to 71 for subsequent lines since we already have a leading space (LP: #1823006), make doctest demonstrate the problem.

This commit is contained in:
Scott Kitterman
2019-04-13 20:53:16 -04:00
parent 118e854889
commit 93e647c8de
+3 -3
View File
@@ -383,8 +383,8 @@ def fold(header, namelen=0):
'x' 'x'
>>> text(fold(b'xyz'*24)) >>> text(fold(b'xyz'*24))
'xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz' 'xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz'
>>> len(fold('abxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxy\\r\\n')) >>> len(fold(b'xyz'*48))
78 150
""" """
# 72 is the max line length we actually want, but the header field name # 72 is the max line length we actually want, but the header field name
# has to fit in the first line too (See Debian Bug #863690). # has to fit in the first line too (See Debian Bug #863690).
@@ -409,7 +409,7 @@ def fold(header, namelen=0):
j = i + 1 j = i + 1
pre += header[:i] + b"\r\n " pre += header[:i] + b"\r\n "
header = header[j:] header = header[j:]
maxleng = 72 maxleng = 71
if len(header) > 2: if len(header) > 2:
return pre + header return pre + header
else: else: