unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Alexander Adolf <alexander.adolf@condition-alpha.com>
To: notmuch@notmuchmail.org
Subject: [PATCH] emacs/smime: render decrypted MIME entities in notmuch-show
Date: Fri, 25 Mar 2022 14:43:45 +0100	[thread overview]
Message-ID: <9cc1c3dc135b5126efd210ee97b88d6b@condition-alpha.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 891 bytes --]

Hello,

kindly find below a patch which I have been using in my local setup for
about a year without seeing any hiccups. So I thought it would be worth
proposing to the developers.

The issue I saw with S/MIME encrypted messages was, that the processing
of the MIME tree stopped after decryption. It turned out there was no
handler for application/(x-)?pkcs-mime type entities in notmuch-show.el,
and the "handler of last resort" notmuch-show-insert-part-*/* was
called. Thus, this patch just adds a notmuch-show handler for
application/(x-)?pkcs-mime type entities.

RFC 8551 defines that there is a single child element only ("A body can
consist of a single MIME entity or a tree of MIME entities (rooted with
a multipart).", clause 3.1), hence no list processing of the children is
needed (there's only one).


Hoping to have helped, and looking forward to your thoughts,

  --alexander


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-emacs-smime-render-decrypted-MIME-entities-in-notmuc.patch --]
[-- Type: text/x-patch, Size: 2116 bytes --]

From d10f4964173ae644077de91b56a98d48f7253ce8 Mon Sep 17 00:00:00 2001
From: Alexander Adolf <alexander.adolf@condition-alpha.com>
Date: Fri, 25 Mar 2022 14:13:28 +0100
Subject: [PATCH] emacs/smime: render decrypted MIME entities in notmuch-show

When processing encrypted S/MIME messages, after decryption the "last
resort" handler notmuch-show-insert-part-*/* was called, because there
was no application/pkcs7-mime handler, resulting in the decrypted
contents not being displayed.

This commit adds a new function
notmuch-show-insert-part-application/pkcs7-mime (and an alias
notmuch-show-insert-part-application/x-pkcs7-mime for the legacy MIME
type) to render the S/MIME protected part after decryption.
---
 emacs/notmuch-show.el | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 7c1f02c9..b7edfc98 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -712,6 +712,23 @@ will return nil if the CID is unknown or cannot be retrieved."
 (defun notmuch-show-insert-part-application/pgp-encrypted (_msg _part _content-type _nth _depth _button)
   t)
 
+(defun notmuch-show-insert-part-application/pkcs7-mime (msg part _content-type _nth depth _button)
+  "Render S/MIME protected content after decryption.
+
+An alias for this function is also defined to handle entities
+using the legacy application/x-pkcs7-mime MIME type."
+  (let* ((encstatus (car (plist-get part :encstatus)))
+	 (inner-part (car (plist-get part :content))))
+    ;; Insert a button detailing the encryption status.
+    (notmuch-crypto-insert-encstatus-button encstatus)
+    (if (not (string= (plist-get encstatus :status) "bad"))
+        ;; Show all decrypted parts.
+        (notmuch-show-insert-bodypart msg inner-part depth))))
+
+;; Support for the legacy "x-" type.
+(fset 'notmuch-show-insert-part-application/x-pkcs7-mime
+  'notmuch-show-insert-part-application/pkcs7-mime)
+
 (defun notmuch-show-insert-part-multipart/* (msg part _content-type _nth depth _button)
   (let ((inner-parts (plist-get part :content))
 	(start (point)))
-- 
2.35.1


[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



             reply	other threads:[~2022-03-25 13:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-25 13:43 Alexander Adolf [this message]
2022-03-29 13:18 ` [PATCH] emacs/smime: render decrypted MIME entities in notmuch-show David Bremner
2022-04-06 20:23   ` Alexander Adolf
2022-04-07 12:25     ` David Bremner
2022-04-07 13:02       ` Alexander Adolf
2022-04-07 14:01         ` David Bremner
2022-04-11 15:35           ` Alexander Adolf
2022-04-11 23:36             ` David Bremner
2022-04-12 16:21               ` Alexander Adolf
2022-04-13 23:56                 ` David Bremner
2022-05-11 15:41                   ` Alexander Adolf
2022-05-16 16:17                   ` Alexander Adolf
2022-05-18 10:29                     ` 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=9cc1c3dc135b5126efd210ee97b88d6b@condition-alpha.com \
    --to=alexander.adolf@condition-alpha.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).