emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 0100e33 2/2: Warn in message.el when sending encryptable mail


From: Lars Ingebrigtsen
Subject: master 0100e33 2/2: Warn in message.el when sending encryptable mail
Date: Sat, 6 Feb 2021 07:26:36 -0500 (EST)

branch: master
commit 0100e33f83eaf1e6698c168c4118cf84a1792496
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Warn in message.el when sending encryptable mail
    
    * lisp/gnus/message.el (message-send): Query if it looks like
    encryption was intended, but is not going to happen.
    
    * lisp/gnus/mml-sec.el (mml-secure-is-encrypted-p): Allow saying
    whether there's any <#secure tags present (bug#24411).
---
 lisp/gnus/message.el |  4 ++++
 lisp/gnus/mml-sec.el | 15 +++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index 6668784..5a5dbce 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -4315,6 +4315,10 @@ It should typically alter the sending method in some way 
or other."
   (when message-confirm-send
     (or (y-or-n-p "Send message? ")
        (keyboard-quit)))
+  (when (and (not (mml-secure-is-encrypted-p))
+            (mml-secure-is-encrypted-p 'anywhere)
+            (not (yes-or-no-p "This message has a <#secure tag, but is not 
going to be encrypted.  Send anyway?")))
+    (error "Aborting sending"))
   (message message-sending-message)
   (let ((alist message-send-method-alist)
        (success t)
diff --git a/lisp/gnus/mml-sec.el b/lisp/gnus/mml-sec.el
index 8d01d15..d41c9dd 100644
--- a/lisp/gnus/mml-sec.el
+++ b/lisp/gnus/mml-sec.el
@@ -298,14 +298,17 @@ Use METHOD if given.  Else use `mml-secure-method' or
   (interactive)
   (mml-secure-part "smime"))
 
-(defun mml-secure-is-encrypted-p ()
-  "Check whether secure encrypt tag is present."
+(defun mml-secure-is-encrypted-p (&optional tag-present)
+  "Whether the current buffer contains a mail message that should be encrypted.
+If TAG-PRESENT, say whether the <#secure tag is present anywhere
+in the buffer."
   (save-excursion
     (goto-char (point-min))
-    (re-search-forward
-     (concat "^" (regexp-quote mail-header-separator) "\n"
-            "<#secure[^>]+encrypt")
-     nil t)))
+    (message-goto-body)
+    (if tag-present
+       (re-search-forward "<#secure[^>]+encrypt" nil t)
+      (skip-chars-forward "[ \t\n")
+      (looking-at "<#secure[^>]+encrypt"))))
 
 (defun mml-secure-bcc-is-safe ()
   "Check whether usage of Bcc is safe (or absent).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]