#1021614 notmuch: RFC2047-encoded special characters in display-name show up unquoted

Package:
notmuch
Source:
notmuch
Description:
thread-based email index, search and tagging
Submitter:
Jakub Wilk
Date:
2024-05-26 12:57:03 UTC
Severity:
normal
Tags:
#1021614#3
Date:
2022-10-11 20:02:31 UTC
From:
To:
The attached message has a bunch of RFC-2047-encoded special characters
in the display-name part of the From field:

    $ grep ^From: weird-from.eml
    From: =?UTF-8?Q?=3Cfoo=40example.org=3E=2C?= <bar@example.org>

When you show this message in notmuch, the special characters show up
unquoted (and unencoded), so that it looks like there are two addresses
in the From field:

    $ ./notmuch-show-from < weird-from.eml
    From: <foo@example.org>, <bar@example.org>

I initially thought this is a GMime bug, but it seems GMime gets this
right:

    $ ./gmime-show-from < weird-from.eml
    From: "<foo@example.org>," <bar@example.org>

#1021614#6
Date:
2022-10-11 20:28:30 UTC
From:
To:
Attaching the reprocucer scripts, which somehow got lost in transport!?
#1021614#13
Date:
2024-05-26 12:52:32 UTC
From:
To:
In [1], Jakub Wilk observes that the current behaviour is confusing
since it looks like there are two mailboxes in From, while in fact
there is only one.  It seems to me that notmuch should at least quote
the display-name part of a mailbox if it has "funny" characters in it,
and perhaps always quote it. Either way will require changing the
indexing code, since the structure is lost when writing the headers to
the database.

[1]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1021614
---
 test/T520-show.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/test/T520-show.sh b/test/T520-show.sh
index 6bcf109c..8121c3db 100755
--- a/test/T520-show.sh
+++ b/test/T520-show.sh
@@ -45,6 +45,12 @@ if [ "${NOTMUCH_HAVE_SFSEXP-0}" = "1" ]; then

 fi

+test_begin_subtest "quoting in From"
+test_subtest_known_broken
+add_message '[from]="=?UTF-8?Q?=3Cfoo=40example.org=3E=2C?= <bar@example.org>"'
+output=$(notmuch show id:${gen_msg_id}|grep From:)
+test_expect_equal "${output}" 'From: "<foo@example.org>," <bar@example.org>'
+
 add_email_corpus duplicate

 ID1=debian/2.6.1.dfsg-4-1-g87ea161@87ea161e851dfb1ea324af00e4ecfccc18875e15