unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH] emacs: mua: check for misplaced secure mml tags
Date: Tue, 27 Sep 2016 21:34:51 +0100	[thread overview]
Message-ID: <1475008491-28175-1-git-send-email-markwalters1009@gmail.com> (raw)

Emacs message-send seems to ignore a secure mml tag anywhere except at
the start of the body. Since this is almost certainly not desired we
check for it, and require user confirmation before sending.

As the setup before message-send or message-send-and-exit is getting
more complicated it is convenient to unify the two correspoinding
notmuch functions.
---

In id:87d1kazlof.fsf@zancas.localnet bremner pointed out there are
some oddities in message mode's handling of the mml secure tag -- that
is ignored if it is not at the start of the body. This definitely
causes a problem with the postpone/resume patch, but could also cause
a problem in normal use.

Since accidentally sending a message unencrypted is rather bad we
check for it. This might also mean that the current postpone/resume
code (which works in many cases) might be useable until a full
solution is found.

Best wishes

Mark


emacs/notmuch-mua.el | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 55bc267..aeb60e2 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -490,15 +490,38 @@ will be addressed to all recipients of the source message."
     (notmuch-mua-reply query-string sender reply-all)
     (deactivate-mark)))
 
+(defun notmuch-mua-misplaced-secure-tag ()
+  "Return t if there is a misplaced secure mml tag.
+
+Emacs message-send will (probably) ignore a secure mml tag
+anywhere except at the start of the body. Since this is almost
+certainly not desired we check for it -- this function returns
+non-nil if there is such a tag."
+  (save-excursion
+    (message-goto-body)
+    (unless (eobp)
+      (forward-char)
+      (search-forward "<#secure" nil 't))))
+
+(defun notmuch-mua-send-common (arg &optional exit)
+  (interactive "P")
+  (letf (((symbol-function 'message-do-fcc) #'notmuch-maildir-message-do-fcc))
+	(when (or (not (notmuch-mua-misplaced-secure-tag))
+		  (yes-or-no-p "\
+There is a <#secure> tag not at the start of the body. It is
+likely that the message will be sent unsigned and unencrypted.
+Really send? "))
+	  (if exit
+	      (message-send-and-exit arg)
+	    (message-send arg)))))
+
 (defun notmuch-mua-send-and-exit (&optional arg)
   (interactive "P")
-  (letf (((symbol-function 'message-do-fcc) #'notmuch-maildir-message-do-fcc))
-	(message-send-and-exit arg)))
+  (notmuch-mua-send-common arg 't))
 
 (defun notmuch-mua-send (&optional arg)
   (interactive "P")
-  (letf (((symbol-function 'message-do-fcc) #'notmuch-maildir-message-do-fcc))
-	(message-send arg)))
+  (notmuch-mua-send-common arg))
 
 (defun notmuch-mua-kill-buffer ()
   (interactive)
-- 
2.1.4

             reply	other threads:[~2016-09-27 20:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-27 20:34 Mark Walters [this message]
2016-09-28 13:15 ` [PATCH] emacs: mua: check for misplaced secure mml tags David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1475008491-28175-1-git-send-email-markwalters1009@gmail.com \
    --to=markwalters1009@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).