- 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
+8 -1
View File
@@ -41,7 +41,14 @@ def compress_whitespace(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):