GNU bug report logs - #77866
30.0.50; message.el handling of non-ascii names in addresses

Previous Next

Package: emacs;

Reported by: Al Haji-Ali <abdo.haji.ali <at> gmail.com>

Date: Thu, 17 Apr 2025 13:01:04 UTC

Severity: normal

Tags: fixed

Found in version 30.0.50

Fixed in version 31.1

Done: Robert Pluim <rpluim <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Robert Pluim <rpluim <at> gmail.com>
To: Al Haji-Ali <abdo.haji.ali <at> gmail.com>
Cc: 77866 <at> debbugs.gnu.org
Subject: bug#77866: 30.0.50; message.el handling of non-ascii names in addresses
Date: Thu, 17 Apr 2025 15:50:10 +0200
>>>>> On Thu, 17 Apr 2025 13:54:21 +0100, Al Haji-Ali <abdo.haji.ali <at> gmail.com> said:

    Abdo> This is a bit difficult for me to reproduce as a user in a
    Abdo> clean instance of Emacs, since I am seeing it in notmuch,
    Abdo> which uses message.el, and I don't know how to use
    Abdo> message.el without my setup of notmuch.  However, I am sure
    Abdo> that I've identified the reason for the bug(?) in message.el
    Abdo> and I hope my description below is sufficient.

    Abdo> I have an email with a header field like this:
    Abdo> CC: "Blanco, Raúl" <blanco <at> test.com>

    Abdo> with a non-ASCII character in the name. When I call
    Abdo> `message-send-mail`, on 29.1 I get an error `split-string:
    Abdo> Wrong type argument: stringp, nil`

    Abdo> and on 30.0.50, I get the error
    Abdo> `Email address can't be parsed`

    Abdo> The reason is that `message-send-mail` calls
    Abdo> `mail-encode-encoded-word-buffer`, which encodes that part
    Abdo> of the message as:

    Abdo> CC: "Blanco, =?utf-8?Q?Ra=C3=BAl=22?= <blanco <at> test.com>

    Abdo> So that the quotation marks are no longer paired, and
    Abdo> `mail-header-parse-addresses` splits the address into two
    Abdo> ill-formed ones.

Thanks for the test code, it made finding the issue easy.

The root cause of this is that `mail-encode-encoded-word-buffer' is
using the `mime' method to encode the value, instead of the
`address-mime' method. Thatʼs because youʼve written the "Cc" header
name as "CC", and the lookup for the method based on the header name
is being done case-sensitively. Patch below fixes it for me (it also
helps if you put a newline at the end of the string youʼre testing)

diff --git a/lisp/mail/rfc2047.el b/lisp/mail/rfc2047.el
index 66760a6595b..db6c0423a54 100644
--- a/lisp/mail/rfc2047.el
+++ b/lisp/mail/rfc2047.el
@@ -265,7 +265,8 @@ rfc2047-encode-message-header
 		 (if (= (length charsets) 1)
 		     (cons (mm-charset-to-coding-system (car charsets))
 			   mm-coding-system-priorities)
-		   mm-coding-system-priorities)))
+		   mm-coding-system-priorities))
+                (case-fold-search t))
 	    (while (setq elem (pop alist))
 	      (when (or (and (stringp (car elem))
 			     (looking-at (car elem)))

Robert
-- 




This bug report was last modified 29 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.