Subject: 30.0.50; message.el handling of non-ascii names in addresses

From: Al Haji-Ali <[email-masked]>
Date: Thu, 17 Apr 2025 13:54:21 +0100

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

I have an email with a header field like this:
CC: "Blanco, Raúl" <[email-masked]>

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

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

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

CC: "Blanco, =?utf-8?Q?Ra=C3=BAl=22?= <[email-masked]>

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

The code below extracts the relevant function calls from `message-send-mail` for an easy check (even on 'emacs -Q'):

,----
| (require 'message)
| (let ((case-fold-search nil))
|   (with-temp-buffer
|     (insert "CC: \"Blanco, Raúl\" <[email-masked]>")
|     (mail-encode-encoded-word-buffer)
|     (cl-loop
|      for addr in
|      (mail-header-parse-addresses
|       (message-fetch-field "CC")
|       t)
|      collect (cons addr (textsec-suspicious-p addr 'email-address-header)))))
`----