From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id wJgQFBnHPWJHAAEAgWs5BA (envelope-from ) for ; Fri, 25 Mar 2022 14:43:53 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id iGeMEBnHPWJ5yQAAauVa8A (envelope-from ) for ; Fri, 25 Mar 2022 14:43:53 +0100 Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 4A97F16BE2 for ; Fri, 25 Mar 2022 14:43:52 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id A42835F72A; Fri, 25 Mar 2022 13:43:49 +0000 (UTC) Received: from smtprelay05.ispgateway.de (smtprelay05.ispgateway.de [80.67.18.28]) by mail.notmuchmail.org (Postfix) with ESMTPS id 3B1555F6C5 for ; Fri, 25 Mar 2022 13:43:47 +0000 (UTC) Received: from [46.244.216.181] (helo=condition-alpha.com) by smtprelay05.ispgateway.de with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nXkEM-0004do-1A for notmuch@notmuchmail.org; Fri, 25 Mar 2022 14:43:54 +0100 Message-Id: <9cc1c3dc135b5126efd210ee97b88d6b@condition-alpha.com> From: Alexander Adolf To: notmuch@notmuchmail.org Subject: [PATCH] emacs/smime: render decrypted MIME entities in notmuch-show Date: Fri, 25 Mar 2022 14:43:45 +0100 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Df-Sender: YWxleGFuZGVyLmFkb2xmQGNvbmRpdGlvbi1hbHBoYS5jb20= Message-ID-Hash: KHUL2S4AQSEAZGASYP2EIE7AD3PNA7VK X-Message-ID-Hash: KHUL2S4AQSEAZGASYP2EIE7AD3PNA7VK X-MailFrom: alexander.adolf@condition-alpha.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1648215833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type:list-id: list-help:list-owner:list-unsubscribe:list-subscribe:list-post; bh=NcMKl0mw4iPETitVVSxLjXkuehFQ+TQPSMXq+tZk8h4=; b=DKErrF7vPPYAmgnQBQwgXq9aKsnJK5VpY3VpZFUC03xi+C7+n/1XinjcukpBifvus0r3Kt dh/te/iOio3lRg7ULwPUmAIdys6KtUUiQ4c5hvjWtkaRC+JDigLnL990D7qBGcXb5/jA0E IJ9bAyNcZQzwlpYr46DVT2FUqDUTxbxP/XaKdERr1JFa+To8JlbbHL6VkV6yalBY+VsEUS cpc22x7fv7HFJPEjcHbW2Q1mKhPSfgthFgz6UJmLQo4w045sYBQ4wjzHY8D0hoMygYwgqh 3XmDBofUwMoz+tz631pUz7ZIywC/op9Dz4xZRWp6X3eBewWst3ZGQ/4XSroRGA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1648215833; a=rsa-sha256; cv=none; b=qf40KbKaA4D1UKI6mSYtHJPP4fmhV+N842Y0oJk5z/f03NPRs39ZzqjikjL0Ym4KdJuQai eF6sjbgJsnYUdUq49mayqX56CS3jVhp6wrKKmy5tbHuJycrax+T0szgxaxbxNbj3gi9Ckg AZ/dBR4qJzImBq9kkvBJk30bnoH50fcs6O1kwDJhiNTX/lbMXHlitdNF8olnhIenQAcDiR 14rVNJYJknI5izF5pV9KblKHbhRD5GLpUvsk5y+/muPqCei03ITnK19oGvV8lPV3Hdqd/r 6lRGov56L6ASCfz7P6Xze2paXIhgxDJZMng+WFBNEaif8NrMTbddfwKQqmHxSQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.01 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 4A97F16BE2 X-Spam-Score: -1.01 X-Migadu-Scanner: scn1.migadu.com X-TUID: j/hDPEkjFLfT --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-emacs-smime-render-decrypted-MIME-entities-in-notmuc.patch >From d10f4964173ae644077de91b56a98d48f7253ce8 Mon Sep 17 00:00:00 2001 From: Alexander Adolf 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 --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --=-=-=--