GNU bug report logs - #42913
[PATCH] Fix issues with OpenPGP header

Previous Next

Package: emacs;

Reported by: "Philip K." <philipk <at> posteo.net>

Date: Tue, 18 Aug 2020 13:23:02 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 42913 in the body.
You can then email your comments to 42913 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#42913; Package emacs. (Tue, 18 Aug 2020 13:23:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Philip K." <philipk <at> posteo.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 18 Aug 2020 13:23:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Philip K." <philipk <at> posteo.net>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Fix issues with OpenPGP header
Date: Tue, 18 Aug 2020 15:21:53 +0200
[Message part 1 (text/plain, inline)]
Hi,

I submitted a patch a few months ago, to generate OpenPGP headers, that
seems like it was a bit faulty. When trying it out today, it didn't seem
to work properly, so I debugged it and made a few changes attached
below.

My appologies for not testing the patch thoroughly enough. I hope
everything is fixed now.

[0001-Fix-issues-with-OpenPGP-header.patch (text/x-patch, inline)]
From 1053988e26dd614aeb4490ae853d2c1c502cc493 Mon Sep 17 00:00:00 2001
From: Philip K <philipk <at> posteo.net>
Date: Tue, 18 Aug 2020 15:12:51 +0200
Subject: [PATCH] Fix issues with OpenPGP header

* doc/misc/message.texi (OpenPGP Header): Mention correct hook
* lisp/gnus/message.el (message-openpgp-header): Improve customize type
(message-add-openpgp-header): Insert header into correct buffer
---
 doc/misc/message.texi |  2 +-
 lisp/gnus/message.el  | 63 ++++++++++++++++++++++---------------------
 2 files changed, 34 insertions(+), 31 deletions(-)

diff --git a/doc/misc/message.texi b/doc/misc/message.texi
index 204a6386e0..55b166eb8b 100644
--- a/doc/misc/message.texi
+++ b/doc/misc/message.texi
@@ -1265,7 +1265,7 @@ OpenPGP Header
 To use this in Message, say:
 
 @lisp
-(add-hook 'message-send-hook 'message-add-openpgp-header)
+(add-hook 'message-header-setup-hook 'message-add-openpgp-header)
 @end lisp
 
 @noindent
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index ab625be9e3..07ff489038 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -2751,16 +2751,17 @@ message-openpgp-header
 or `message-openpgp-header' is itself nil, the OpenPGP header
 will not be inserted."
   :type '(choice
-	  (const nil :tag "Don't add OpenPGP header")
-	  (list (choice (string :tag "ID")
-			(const nil :tag "No ID"))
+	  (const :tag "Don't add OpenPGP header" nil)
+	  (list :tag "Use OpenPGP header"
+		(choice (string :tag "ID")
+			(const :tag "No ID" nil))
 		(choice (string :tag "Key")
-			(const nil :tag "No Key"))
-		(choice (other nil :tag "None")
-			(const "unprotected" :tag "Unprotected")
-			(const "sign" :tag "Sign")
-			(const "encrypt" :tag "Encrypt")
-			(const "signencrypt" :tag "Sign and Encrypt"))))
+			(const :tag "No Key" nil))
+		(choice (other :tag "None" nil)
+			(const :tag "Unprotected" "unprotected")
+			(const :tag "Sign" "sign")
+			(const :tag "Encrypt" "encrypt")
+			(const :tag "Sign and Encrypt" "signencrypt"))))
   :version "28.1")
 
 (defun message-add-openpgp-header ()
@@ -2768,32 +2769,34 @@ message-add-openpgp-header
 
 Header will be constructed as specified in `message-openpgp-header'.
 
-Consider adding this function to `message-send-hook'."
+Consider adding this function to `message-header-setup-hook'"
   ;; See https://tools.ietf.org/html/draft-josefsson-openpgp-mailnews-header
   (when (and message-openpgp-header
 	     (or (nth 0 message-openpgp-header)
 		 (nth 1 message-openpgp-header)
 		 (nth 2 message-openpgp-header)))
-    (with-temp-buffer
-      (insert "OpenPGP: ")
-      ;; add ID
-      (let (need-sep)
-	(when (nth 0 message-openpgp-header)
-	  (insert "id=" (nth 0 message-openpgp-header))
-	  (setq need-sep t))
-	;; add URL
-	(when (nth 1 message-openpgp-header)
-	  (when need-sep (insert "; "))
-	  (if (string-match-p ";")
-	      (insert "url=\"" (nth 1 message-openpgp-header) "\"")
-	    (insert "url=\"" (nth 1 message-openpgp-header) "\""))
-	  (setq need-sep t))
-	;; add preference
-	(when (nth 2 message-openpgp-header)
-	  (when need-sep (insert "; "))
-	  (insert "preference=" (nth 2 message-openpgp-header))))
-      ;; insert header
-      (message-add-header (buffer-string)))))
+    (message-add-header
+     (with-temp-buffer
+       (insert "OpenPGP: ")
+       ;; add ID
+       (let (need-sep)
+	 (when (nth 0 message-openpgp-header)
+	   (insert "id=" (nth 0 message-openpgp-header))
+	   (setq need-sep t))
+	 ;; add URL
+	 (when (nth 1 message-openpgp-header)
+	   (when need-sep (insert "; "))
+	   (if (string-match-p ";")
+	       (insert "url=\"" (nth 1 message-openpgp-header) "\"")
+	     (insert "url=\"" (nth 1 message-openpgp-header) "\""))
+	   (setq need-sep t))
+	 ;; add preference
+	 (when (nth 2 message-openpgp-header)
+	   (when need-sep (insert "; "))
+	   (insert "preference=" (nth 2 message-openpgp-header))))
+       ;; insert header
+       (buffer-string)))
+    (message-sort-headers)))
 
 
 
-- 
2.26.2


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#42913; Package emacs. (Tue, 18 Aug 2020 16:07:02 GMT) Full text and rfc822 format available.

Message #8 received at 42913 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: "Philip K." <philipk <at> posteo.net>
Cc: 42913 <at> debbugs.gnu.org
Subject: Re: bug#42913: [PATCH] Fix issues with OpenPGP header
Date: Tue, 18 Aug 2020 18:06:34 +0200
"Philip K." <philipk <at> posteo.net> writes:

> I submitted a patch a few months ago, to generate OpenPGP headers, that
> seems like it was a bit faulty. When trying it out today, it didn't seem
> to work properly, so I debugged it and made a few changes attached
> below.

Thanks; applied to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 18 Aug 2020 16:07:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 42913 <at> debbugs.gnu.org and "Philip K." <philipk <at> posteo.net> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 18 Aug 2020 16:07:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 16 Sep 2020 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 276 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.