This is intended to help track down a display problem in the emacs front end --- test/T357-index-decryption.sh | 1 + .../crypto/encrypted-rfc822-attachment | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 test/corpora/crypto/encrypted-rfc822-attachment diff --git a/test/T357-index-decryption.sh b/test/T357-index-decryption.sh index a96c1b5e..a7497489 100755 --- a/test/T357-index-decryption.sh +++ b/test/T357-index-decryption.sh @@ -226,6 +226,7 @@ output=$(notmuch dump | LC_ALL=C sort) expected='#= simple-encrypted@crypto.notmuchmail.org index.decryption=failure #notmuch-dump batch-tag:3 config,properties,tags +encrypted +inbox +unread -- id:basic-encrypted@crypto.notmuchmail.org ++encrypted +inbox +unread -- id:encrypted-rfc822-attachment@crypto.notmuchmail.org +encrypted +inbox +unread -- id:encrypted-signed@crypto.notmuchmail.org +encrypted +inbox +unread -- id:simple-encrypted@crypto.notmuchmail.org' test_expect_equal \ diff --git a/test/corpora/crypto/encrypted-rfc822-attachment b/test/corpora/crypto/encrypted-rfc822-attachment new file mode 100644 index 00000000..56fe3169 --- /dev/null +++ b/test/corpora/crypto/encrypted-rfc822-attachment @@ -0,0 +1,52 @@ +Content-Type: multipart/encrypted; protocol="application/pgp-encrypted"; boundary="===============9060418334135509864==" +MIME-Version: 1.0 +From: Notmuch test suite <test_suite@notmuchmail.org> +To: test_suite@notmuchmail.org +Subject: testing encrypted rfc822 attachments +Date: Sat, 03 Jul 2021 16:00:02 -0300 +Message-ID: <encrypted-rfc822-attachment@crypto.notmuchmail.org> +User-Agent: alot/0.9.1 + +--===============9060418334135509864== +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: application/pgp-encrypted; charset="us-ascii" + +Version: 1 +--===============9060418334135509864== +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: application/octet-stream; charset="us-ascii" + +-----BEGIN PGP MESSAGE----- + +hIwDxE023q1UqxYBBACGKSDv5/rcwScSf9n33cZZPPxltQgxkDaClMGY2DARgebE +9rpE2O/4eoaEbdu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dsafaQ9B +BkuVGu6cIDa6STyCJiOB68KIXiDuADSWJiiR+gZr4eU6vzfhR27LMQt/g+oPW+U4 +1AvzUl9uXjTMC2vFuTQ4M2g0WmksCNpPpzOu/QlBmRqpP2Fg9UuLv6ITWeCxp439 +g5NT5KXE2IiruL/DS0KEpWVNe4ayGzRvMawFuU582xbIzXjvilUZrW+p6req+oeF +QWTWHGDojTvULQPV2c91lWnLaNXVethfF4hrM5MIL+EwVs3sUXFMr1kX7VNrK0QH +Uos7nc4G9xngpdvwF4ImldD83O8qxOVzIfk5Dhz+etTH4HbnnDvmQ/FIYvjzGviR +ZeVwdCjv/9TC4yY3nJFKMwGp70jVa1vbmWL68HVNRyAVwnQnu2UlI8UR43iVZyUH +ZY0Nr0rbse/pvZyX4//EVOFLUR7K4GG0N4Kz41q5ZB8rI4Fl6QJhgIFJds13iM77 +n+wqLQE7kllgI32E4U9B +=YlXg +-----END PGP MESSAGE----- + +--===============9060418334135509864==-- -- 2.30.2
There are at least 3 bugs present. 1) notmuch-show-insert-part-message/rfc822 assumes that message/rfc822 parts will have a ":content" property, but that turns out not to be the case. 2) something deep in gnus wants gnus-newsgroup-charset, but that is defined in gnus-sum, which is not loaded by default. 3) If gnus-sum is loaded, then the display of the message/rfc822 part succeeds, but the buffer gets put into gnus-article-mode, which means that, inter alia, notmuch text properties and keybindings get wiped. --- test/T450-emacs-show.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh index 9d08d2cc..bf7c1fe0 100755 --- a/test/T450-emacs-show.sh +++ b/test/T450-emacs-show.sh @@ -219,6 +219,13 @@ test_emacs '(notmuch-show "id:basic-encrypted@crypto.notmuchmail.org") (test-visible-output)' test_expect_equal_file $EXPECTED/notmuch-show-decrypted-message OUTPUT +test_begin_subtest "show encrypted rfc822 message" +test_subtest_known_broken +test_emacs '(notmuch-show "id:encrypted-rfc822-attachment@crypto.notmuchmail.org") + (test-visible-output)' +fgrep '!!!' OUTPUT > OUTPUT.err +test_expect_equal_file /dev/null OUTPUT.err + test_begin_subtest "show undecryptable message" test_emacs '(notmuch-show "id:simple-encrypted@crypto.notmuchmail.org") (test-visible-output)' -- 2.30.2
On Sat, Jul 03 2021, David Bremner wrote: > There are at least 3 bugs present. > > 1) notmuch-show-insert-part-message/rfc822 assumes that message/rfc822 > parts will have a ":content" property, but that turns out not to be > the case. > > 2) something deep in gnus wants gnus-newsgroup-charset, but that is > defined in gnus-sum, which is not loaded by default. > > 3) If gnus-sum is loaded, then the display of the message/rfc822 part > succeeds, but the buffer gets put into gnus-article-mode, which means > that, inter alia, notmuch text properties and keybindings get wiped. > --- > test/T450-emacs-show.sh | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh > index 9d08d2cc..bf7c1fe0 100755 > --- a/test/T450-emacs-show.sh > +++ b/test/T450-emacs-show.sh > @@ -219,6 +219,13 @@ test_emacs '(notmuch-show "id:basic-encrypted@crypto.notmuchmail.org") > (test-visible-output)' > test_expect_equal_file $EXPECTED/notmuch-show-decrypted-message OUTPUT > > +test_begin_subtest "show encrypted rfc822 message" > +test_subtest_known_broken > +test_emacs '(notmuch-show "id:encrypted-rfc822-attachment@crypto.notmuchmail.org") > + (test-visible-output)' > +fgrep '!!!' OUTPUT > OUTPUT.err > +test_expect_equal_file /dev/null OUTPUT.err In this case one could just do test_expect_code 1 "fgrep -q '!!!' OUTPUT" (these file comparisons w/ /dev/null (currently 5) annoys me ;/ so if I am biased the current suggestion is fine) Tomi > + > test_begin_subtest "show undecryptable message" > test_emacs '(notmuch-show "id:simple-encrypted@crypto.notmuchmail.org") > (test-visible-output)' > -- > 2.30.2
This is not finished/correct yet, but maybe it will save someone else some debugging. [PATCH 1/3] emacs: forcibly set notmuch-show-mode after delegating - In particular this resets some variables to default values which breaks the indentation test. [PATCH 2/3] emacs: don't inline message/rfc822 parts without content - of the three patches, this seems like the most sane. The content isn't there, so either the function needs to be rewritten to handle re-parsing the blob, or just fail gracefully [PATCH 3/3] emacs: dynamically bind gnus-newsgroup-charset - this is very much papering over the symptoms
Some mm-* functions end up calling (gnus-article-mode), which breaks notmuch. --- emacs/notmuch-lib.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index c7bb2091..8ca416d4 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -694,6 +694,8 @@ current buffer, if possible." (when (mm-inlinable-p handle) (set-buffer display-buffer) (mm-display-part handle) + ;; restore major mode if changed by gnus + (notmuch-show-mode) t)))))) ;;; Generic Utilities -- 2.30.2
This avoids some ugly error messages and exceptions, and hopes that some gnus method will display message/rfc822 parts that have only a file, no :content part. --- emacs/notmuch-show.el | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 9a95eb34..7695e869 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -718,21 +718,23 @@ will return nil if the CID is unknown or cannot be retrieved." t) (defun notmuch-show-insert-part-message/rfc822 (msg part _content-type _nth depth _button) - (let* ((message (car (plist-get part :content))) - (body (car (plist-get message :body))) - (start (point))) - ;; Override `notmuch-message-headers' to force `From' to be - ;; displayed. - (let ((notmuch-message-headers '("From" "Subject" "To" "Cc" "Date"))) - (notmuch-show-insert-headers (plist-get message :headers))) - ;; Blank line after headers to be compatible with the normal - ;; message display. - (insert "\n") - ;; Show the body - (notmuch-show-insert-bodypart msg body depth) - (when notmuch-show-indent-multipart - (indent-rigidly start (point) 1))) - t) + (let ((message (car (plist-get part :content)))) + (and + message + (let ((body (car (plist-get message :body))) + (start (point))) + ;; Override `notmuch-message-headers' to force `From' to be + ;; displayed. + (let ((notmuch-message-headers '("From" "Subject" "To" "Cc" "Date"))) + (notmuch-show-insert-headers (plist-get message :headers))) + ;; Blank line after headers to be compatible with the normal + ;; message display. + (insert "\n") + ;; Show the body + (notmuch-show-insert-bodypart msg body depth) + (when notmuch-show-indent-multipart + (indent-rigidly start (point) 1)) + t)))) (defun notmuch-show-insert-part-text/plain (msg part _content-type _nth depth button) ;; For backward compatibility we want to apply the text/plain hook -- 2.30.2
This avoids requiring gnus-sum, which is currently where this variable is defined. --- emacs/notmuch-lib.el | 3 ++- test/T450-emacs-show.sh | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 8ca416d4..37fb4018 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -693,7 +693,8 @@ current buffer, if possible." (insert (notmuch-get-bodypart-binary msg part process-crypto))) (when (mm-inlinable-p handle) (set-buffer display-buffer) - (mm-display-part handle) + (notmuch-dlet ((gnus-newsgroup-charset nil)) + (mm-display-part handle)) ;; restore major mode if changed by gnus (notmuch-show-mode) t)))))) diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh index 75a52640..7a731ac7 100755 --- a/test/T450-emacs-show.sh +++ b/test/T450-emacs-show.sh @@ -220,7 +220,6 @@ test_emacs '(notmuch-show "id:basic-encrypted@crypto.notmuchmail.org") test_expect_equal_file $EXPECTED/notmuch-show-decrypted-message OUTPUT test_begin_subtest "show encrypted rfc822 message" -test_subtest_known_broken test_emacs '(notmuch-show "id:encrypted-rfc822-attachment@crypto.notmuchmail.org") (test-visible-output)' count=$(fgrep -c '!!!' OUTPUT) -- 2.30.2
Tomi Ollila <tomi.ollila@iki.fi> writes:
> In this case one could just do
>
> test_expect_code 1 "fgrep -q '!!!' OUTPUT"
>
> (these file comparisons w/ /dev/null (currently 5) annoys me ;/
> so if I am biased the current suggestion is fine)
Sure, I've adopted your suggestion in git
d
David Bremner <david@tethera.net> writes:
> This is not finished/correct yet, but maybe it will save someone else
> some debugging.
>
> [PATCH 2/3] emacs: don't inline message/rfc822 parts without content
>
I have confirmed that thanks to larsi's quick fix, patch 2/3 alone makes
things copacetic in emacs master. I have marked the other two patches as
obsolete, although if people thing this case is important enough, we
could try to work around the issues with pre-28 emacs in a more
careful way.
Antoine, is this a common annoyance for you, or a rare issue?
d
On 2021-07-06 12:49:23, David Bremner wrote:
> David Bremner <david@tethera.net> writes:
>
>> This is not finished/correct yet, but maybe it will save someone else
>> some debugging.
>>
>> [PATCH 2/3] emacs: don't inline message/rfc822 parts without content
>>
>
> I have confirmed that thanks to larsi's quick fix, patch 2/3 alone makes
> things copacetic in emacs master. I have marked the other two patches as
> obsolete, although if people thing this case is important enough, we
> could try to work around the issues with pre-28 emacs in a more
> careful way.
>
> Antoine, is this a common annoyance for you, or a rare issue?
I actually fumble upon similar errors somewhat frequently, but it's the
first time it's reproducible. Typically, it happens under other, more
neboulous circumstances and the fix then is to restart emacs (!).
Are you saying the fix is to upgrade to emacs 28?
a.
--
Ou bien Dieu voudrait supprimer le mal, mais il ne le peut pas
Ou bien Dieu pourrait supprimer le mal, mais il ne le veut pas.
- Sébastien Faure
Antoine Beaupré <anarcat@debian.org> writes:
> On 2021-07-06 12:49:23, David Bremner wrote:
>> David Bremner <david@tethera.net> writes:
>>
>>> This is not finished/correct yet, but maybe it will save someone else
>>> some debugging.
>>>
>>> [PATCH 2/3] emacs: don't inline message/rfc822 parts without content
>>>
>>
>> I have confirmed that thanks to larsi's quick fix, patch 2/3 alone makes
>> things copacetic in emacs master. I have marked the other two patches as
>> obsolete, although if people thing this case is important enough, we
>> could try to work around the issues with pre-28 emacs in a more
>> careful way.
>>
>> Antoine, is this a common annoyance for you, or a rare issue?
>
> I actually fumble upon similar errors somewhat frequently, but it's the
> first time it's reproducible. Typically, it happens under other, more
> neboulous circumstances and the fix then is to restart emacs (!).
>
> Are you saying the fix is to upgrade to emacs 28?
Pretty much. Along with a patch to notmuch, if you care about the
display of !!! error messages. Of course, Emacs 28 is unreleased
software, so may have other uncomfortable aspects.
On 2021-07-09 07:23:55, David Bremner wrote:
> Antoine Beaupré <anarcat@debian.org> writes:
>
>> On 2021-07-06 12:49:23, David Bremner wrote:
>>> David Bremner <david@tethera.net> writes:
>>>
>>>> This is not finished/correct yet, but maybe it will save someone else
>>>> some debugging.
>>>>
>>>> [PATCH 2/3] emacs: don't inline message/rfc822 parts without content
>>>>
>>>
>>> I have confirmed that thanks to larsi's quick fix, patch 2/3 alone makes
>>> things copacetic in emacs master. I have marked the other two patches as
>>> obsolete, although if people thing this case is important enough, we
>>> could try to work around the issues with pre-28 emacs in a more
>>> careful way.
>>>
>>> Antoine, is this a common annoyance for you, or a rare issue?
>>
>> I actually fumble upon similar errors somewhat frequently, but it's the
>> first time it's reproducible. Typically, it happens under other, more
>> neboulous circumstances and the fix then is to restart emacs (!).
>>
>> Are you saying the fix is to upgrade to emacs 28?
>
> Pretty much. Along with a patch to notmuch, if you care about the
> display of !!! error messages. Of course, Emacs 28 is unreleased
> software, so may have other uncomfortable aspects.
I'm not at a place in my life where I compile my own Emacs. Once a upon
a time, that was a thing, before I found out about binary
distributions. But those days are (fortunately) over. ;)
a.
--
A developed country is not a place where the poor have cars. It's
where the rich use public transportation.
- Gustavo Petro
David Bremner <david@tethera.net> writes:
> Tomi Ollila <tomi.ollila@iki.fi> writes:
>
>> In this case one could just do
>>
>> test_expect_code 1 "fgrep -q '!!!' OUTPUT"
>>
>> (these file comparisons w/ /dev/null (currently 5) annoys me ;/
>> so if I am biased the current suggestion is fine)
>
> Sure, I've adopted your suggestion in git
>
> d
and applied that version to master.
d
David Bremner <david@tethera.net> writes:
> This avoids some ugly error messages and exceptions, and hopes that
> some gnus method will display message/rfc822 parts that have only a
> file, no :content part.
applied to master