- Correctly fold lines at or near the maximum line length (fix folding
zero length lines and adding a blank line and adding an exra cr/lf for
lines near max length (LP: #1717576)
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
2018-06-16 Version 0.8.1
|
||||
- Correctly fold lines at or near the maximum line length (fix folding
|
||||
zero length lines and adding a blank line and adding an exra cr/lf for
|
||||
lines near max length (LP: #1717576)
|
||||
- Thanks to Christian Jørgensen and John Levine for reporting the issue
|
||||
|
||||
2018-05-18 Version 0.8.0
|
||||
- Change from distutils to setuptools with entry points because it's the
|
||||
future
|
||||
- Use install_requires and extras_requires to document external
|
||||
dependencies for dkimpy (LP: #1227526)
|
||||
- Fix typo in dknewky(1) for k= tag (Thanks to Andreas Schulze for
|
||||
- Fix typo in dknewkey(1) for k= tag (Thanks to Andreas Schulze for
|
||||
reporting)
|
||||
- Detect incorrect version in DKIM public key record (LP: #1763815)
|
||||
- Detect unknown algorithm in k= tag and raise an appropriate error, vice
|
||||
|
||||
+17
-3
@@ -352,7 +352,18 @@ def fold(header, namelen=0):
|
||||
' foo'
|
||||
>>> len(fold(b'foo'*25).splitlines()[0])
|
||||
72
|
||||
>>> text(fold(b'x'))
|
||||
'x'
|
||||
>>> text(fold(b'xyz'*24))
|
||||
'xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz'
|
||||
"""
|
||||
# 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).
|
||||
maxleng = 72 - namelen
|
||||
if len(header) <= maxleng:
|
||||
return header
|
||||
if len(header) - header.rfind(b"\r\n") == 2 and len(header) <= maxleng +2:
|
||||
return header
|
||||
i = header.rfind(b"\r\n ")
|
||||
if i == -1:
|
||||
pre = b""
|
||||
@@ -360,9 +371,6 @@ def fold(header, namelen=0):
|
||||
i += 3
|
||||
pre = header[:i]
|
||||
header = header[i:]
|
||||
# 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).
|
||||
maxleng = 72 - namelen
|
||||
while len(header) > maxleng:
|
||||
i = header[:maxleng].rfind(b" ")
|
||||
if i == -1:
|
||||
@@ -372,6 +380,12 @@ def fold(header, namelen=0):
|
||||
pre += header[:j] + b"\r\n "
|
||||
header = header[j:]
|
||||
namelen = 0
|
||||
if len(header) > 2:
|
||||
return pre + header
|
||||
else:
|
||||
if pre[0] == b' ':
|
||||
return pre[:-1]
|
||||
else:
|
||||
return pre + header
|
||||
|
||||
def load_pk_from_dns(name, dnsfunc=get_txt):
|
||||
|
||||
Reference in New Issue
Block a user