From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Philip K." Newsgroups: gmane.emacs.bugs Subject: bug#42913: [PATCH] Fix issues with OpenPGP header Date: Tue, 18 Aug 2020 15:21:53 +0200 Message-ID: <87tux0qeby.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6859"; mail-complaints-to="usenet@ciao.gmane.io" To: 42913@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 18 15:23:10 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k81a1-0001h0-RB for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 18 Aug 2020 15:23:09 +0200 Original-Received: from localhost ([::1]:52906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k81a0-0007NH-Jk for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 18 Aug 2020 09:23:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k81Zu-0007N5-SY for bug-gnu-emacs@gnu.org; Tue, 18 Aug 2020 09:23:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51183) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k81Zu-00017j-IC for bug-gnu-emacs@gnu.org; Tue, 18 Aug 2020 09:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1k81Zu-00022y-Do for bug-gnu-emacs@gnu.org; Tue, 18 Aug 2020 09:23:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Philip K." Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 18 Aug 2020 13:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 42913 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15977569277793 (code B ref -1); Tue, 18 Aug 2020 13:23:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 18 Aug 2020 13:22:07 +0000 Original-Received: from localhost ([127.0.0.1]:34496 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k81Z1-00021d-El for submit@debbugs.gnu.org; Tue, 18 Aug 2020 09:22:07 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:60762) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k81Yw-00021F-5x for submit@debbugs.gnu.org; Tue, 18 Aug 2020 09:22:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k81Yv-0007HC-N1 for bug-gnu-emacs@gnu.org; Tue, 18 Aug 2020 09:22:01 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:35127) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k81Ys-00012r-Q4 for bug-gnu-emacs@gnu.org; Tue, 18 Aug 2020 09:22:01 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id 8A5832400FD for ; Tue, 18 Aug 2020 15:21:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1597756914; bh=7cqrZZtvmMy2dozfnP5//E6SfhKnGv3zH6aIfr0t43g=; h=From:To:Subject:Date:OpenPGP:From; b=AzejrEh12lh/WjKCjQlwZqZf68gz6e+ojRZpCqpNbexCqXSKUqIIXaW3z8S0qkrff swvtnRufaGZwOF6bGSCHum0G2RxAYJNZuqf88mbbhh5f8uwt+znehxG+yVh7eh0YVt jzceCBAicfQYmuCxamhe3wLFjmjHx0VWp84WtstIV+q1aSlu7u4G1r/MVYqr1O5hex Ef8G8+UToKzOxnFMGhD/MRxgy1cuEVuOGilaqHvjbSdpGzNEjVXv7oDzMpvxjE/lUW PkmOa+3EgdNH2czPGEKIxMYr4ZY0iDQ8CN3SvtCv+MF4q8J92VO6LiZwkqFD40ec5r Y0RKdm6zNMKfg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4BWBQT73dzz9rxm for ; Tue, 18 Aug 2020 15:21:53 +0200 (CEST) OpenPGP: id=6D6F982F77B468D9D8A2C8C8181F5B95AE30B336 Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/18 09:21:54 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:185473 Archived-At: --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Fix-issues-with-OpenPGP-header.patch >From 1053988e26dd614aeb4490ae853d2c1c502cc493 Mon Sep 17 00:00:00 2001 From: Philip K 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 --=-=-=--