summaryrefslogtreecommitdiff
path: root/alot/helper.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2017-07-17 16:39:02 -0700
committerDylan Baker <dylan@pnwbakers.com>2017-07-17 16:39:02 -0700
commit22ad7af98ad1daaf8ccef6515acefeb3b964730e (patch)
tree075b001d314f62a720affb7a920dd9870cd530ba /alot/helper.py
parent9406ce0379c7aec54a6ac9ba9ae7dc4c785ff082 (diff)
helper: Do not add a newline to the end of a signed section
The spec is very clear here: (2) An appropriate Content-Transfer-Encoding is then applied; see section 3. In particular, line endings in the encoded data MUST use the canonical <CR><LF> sequence where appropriate (note that the canonical line ending may or may not be present on the last line of encoded data and MUST NOT be included in the signature if absent). That very last MUST NOT is what's important here, we shouldn't be adding newlines if they weren't there to begin with. Because we do it causes signed blobs that have newlines to be invalid since we've changed the substance of the signed code.
Diffstat (limited to 'alot/helper.py')
-rw-r--r--alot/helper.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/alot/helper.py b/alot/helper.py
index b73ee7b1..effec6b3 100644
--- a/alot/helper.py
+++ b/alot/helper.py
@@ -585,8 +585,7 @@ def RFC3156_canonicalize(text):
This function works as follows (in that order):
1. Convert all line endings to \\\\r\\\\n (DOS line endings).
- 2. Ensure the text ends with a newline (\\\\r\\\\n).
- 3. Encode all occurences of "From " at the beginning of a line
+ 2. Encode all occurences of "From " at the beginning of a line
to "From=20" in order to prevent other mail programs to replace
this with "> From" (to avoid MBox conflicts) and thus invalidate
the signature.
@@ -595,8 +594,6 @@ def RFC3156_canonicalize(text):
:rtype: str
"""
text = re.sub("\r?\n", "\r\n", text)
- if not text.endswith("\r\n"):
- text += "\r\n"
text = re.sub("^From ", "From=20", text, flags=re.MULTILINE)
return text