Skip to content

Instantly share code, notes, and snippets.

@tbielawa
Created March 3, 2012 21:47
Show Gist options
  • Save tbielawa/1968446 to your computer and use it in GitHub Desktop.
Save tbielawa/1968446 to your computer and use it in GitHub Desktop.
Thoughts?
From 75867d8090898a23c86b40aa69952c8921b4b711 Mon Sep 17 00:00:00 2001
From: Tim Bielawa <tbielawa@redhat.com>
Date: Sat, 3 Mar 2012 15:56:25 -0500
Subject: [PATCH] Fix mml-quoting in responses where pgp-signing is enabled
The addition of mml-quote-region (notmuch-mua.el) in 2c6710e3 breaks
automatic signing in replies. When replies are mml-quoted and signing
is enabled by default the "<#part sign=pgpmime>" string will appear on
line 1. This will be consumed during the application of the
mml-quote-region function and transform into the inert string
"<#!part sign=pgpmime>". The result is that responses will no longer
be signed by default.
This fix moves the point forward one line before applying the quoting
function.
Consideration: Clients not signing mail by default. The first line of
their responses would be skipped when the quoting function is
applied. This string takes this general form:
On Sat, 03 Mar 2012 12:55:14 -0800, notmuch-request@notmuchmail.org wrote:
Because the string is generated by notmuch I don't believe this fix
introduces the possibility for malicious mml commands being omitted
from the quoting.
---
emacs/notmuch-mua.el | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 4be7c13..c59a2cf 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -114,14 +114,25 @@ list."
(goto-char (point-max)))
(insert body)
(push-mark))
- (set-buffer-modified-p nil)
(message-goto-body)
;; Original message may contain (malicious) MML tags. We must
;; properly quote them in the reply. Note that using `point-max'
;; instead of `mark' here is wrong. The buffer may include user's
- ;; signature which should not be MML-quoted.
- (mml-quote-region (point) (mark)))
+ ;; signature which should not be MML-quoted.
+ ;;
+ ;; Note also that we skip the first line of the response as it is
+ ;; either: the "<#part sign=pgpmime>" string when clients use
+ ;; automatic signing, or it is the generated string from notmuch
+ ;; indicating the date and author of the message which is being
+ ;; responded to, "on date x, y z -0000, foo@bar.com wrote:"
+ (forward-line 1)
+ (mml-quote-region (point) (mark))
+
+ ;; Quoting the message may modify the contents of the buffer,
+ ;; however, we shouldn't consider mml-quoting a modification because
+ ;; it's preformed by the mua, not the user.
+ (set-buffer-modified-p nil))
(defun notmuch-mua-forward-message ()
(message-forward)
--
1.7.4.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment