Subject: Re: bug#56824: 29.0.50; mail-header-parse-address drops the 1st character from the name

From: Sam Steingold <[email-masked]>
Date: Fri, 29 Jul 2022 09:58:26 -0400

> * Lars Ingebrigtsen <[email-masked]> [2022-07-29 15:36:20 +0200]:
>
> Sam Steingold <[email-masked]> writes:
>
>> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=10406
>> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=56422
>>
>> Lars told me to use `mail-header-parse-address' instead of
>> `mail-extract-address-components'.
>
> Well, not exactly.

oops. sorry. ;-)

>> Well, I tried, with a positive effect (thanks Lars!),
>> but here is the 1st time the former is deficient:
>>
>> (mail-header-parse-addresses "Štěpán Němec <[email-masked]>")
>> ==> (("[email-masked]" . "těpán Němec"))
>> (mail-extract-address-components "Štěpán Němec <[email-masked]>")
>> ==> ("Štěpán Němec" "[email-masked]")
>
> `mail-header-parse-addresses' is for parsing RFC822bis mail addresses.
> "Štěpán Němec <[email-masked]>" is definitely not one of those.

Hmmm, it _used to be_
--8<---------------cut here---------------start------------->8---
"=?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= <[email-masked]>"
--8<---------------cut here---------------end--------------->8---
(is that what RFC822bis specifies?)

but was passed through `mail-decode-encoded-word-string':
--8<---------------cut here---------------start------------->8---
(mail-decode-encoded-word-string "=?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= <[email-masked]>")
==> "Štěpán Němec <[email-masked]>"
--8<---------------cut here---------------end--------------->8---
and then passed on to `mail-header-parse-addresses'.

What is TRT here?

Should I call `mail-header-parse-addresses' _first_ and then
`mail-decode-encoded-word-string'?
Come to think of it, passing _email address_ through
`mail-decode-encoded-word-string' seems unnecessary...

--8<---------------cut here---------------start------------->8---
(mail-header-parse-addresses "=?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= <[email-masked]>")
==> (("[email-masked]" . "=?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?="))
(mail-decode-encoded-word-string "=?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?=")
==> "Štěpán Němec"
--8<---------------cut here---------------end--------------->8---

> You're probably looking for `mail-header-parse-address-lax':
>
> (mail-header-parse-address-lax "Štěpán Němec <[email-masked]>")
> -> ("[email-masked]" . "Štěpán Němec")

... Or maybe I should keep the current order of processing and use
`mail-header-parse-address-lax'?

Thank you for your speedy and enlightening reply!

-- 
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.2113
http://childpsy.net http://calmchildstories.com http://steingoldpsychology.com
http://think-israel.org https://thereligionofpeace.com https://iris.org.il
In the race between idiot-proof software and idiots, the idiots are winning.