- Python 3.7 compatibility fixup for dkim.canonicalization.

strip_trailing_lines due to changed RE.sub() processing (LP: #1800313)
This commit is contained in:
Scott Kitterman
2018-10-29 19:53:12 -04:00
parent b81797bc70
commit 3c2beaf70e
2 changed files with 10 additions and 1 deletions
+2
View File
@@ -3,6 +3,8 @@ UNRELEASED Version 0.9.0
(Thomas Ward) (Thomas Ward)
- PEP8 Blank Lines Style Issues (LP: #1782596) - PEP8 Blank Lines Style Issues (LP: #1782596)
(Thomas Ward) (Thomas Ward)
- Python 3.7 compatibility fixup for dkim.canonicalization.
strip_trailing_lines due to changed RE.sub() processing (LP: #1800313)
2018-06-16 Version 0.8.1 2018-06-16 Version 0.8.1
- Correctly fold lines at or near the maximum line length (fix folding - Correctly fold lines at or near the maximum line length (fix folding
+8 -1
View File
@@ -41,7 +41,14 @@ def compress_whitespace(content):
def strip_trailing_lines(content): def strip_trailing_lines(content):
return re.sub(b"(\r\n)*$", b"\r\n", content) content = re.sub(b"(\r\n)*$", b"\r\n", content)
# Yes, this is horrible, but regex processing changed in python3.7 and it
# is the least horrible solution I came up with for python2.7, python3.7,
# and python3 << 3.7 combined support. Better solution welcome.
if len(content) >= 4:
if (content[len(content)-4:] == b'\r\n\r\n'):
content = content[:len(content)-2]
return content
def unfold_header_value(content): def unfold_header_value(content):