Subject: 24.4; Bad handling of RFC2047 encoded headers by 'mail-extract-address-components'

From: Enrico Scholz <[email-masked]>
Date: Mon, 22 Dec 2014 16:10:56 +0100

Hi,

the emacs email framework fails on email addresses containing umlauts.
E.g. in the following example

--- {{{ snip ---
; set a (nearly) real-world To: address; the umlaut '=C3=A4' encoding
; was replaced by '=61=65'
(let* ((address "=?utf-8?Q?B=61=65Br=2C_Klaus?= <[email-masked]>")
       (decoded (rfc2047-decode-string address)))
  ; show output with encoded umlauts and non-RFC2047 header
  (print (mail-extract-address-components "\"Baer, Klaus\" <[email-masked]>"))
  (print address t)
  (print decoded t)
  ; previous prints were just for debugging purposes; now, the real
  ; functions will be called...
  (print (mail-extract-address-components address))
  (print (mail-extract-address-components decoded)))
--- }}} snip ---

none of the last two debug outputs show the expected split.

| ("Klaus Baer" "[email-masked]")            <--- this is expected
| 
| "=?utf-8?Q?B=61=65r=2C_Klaus?= <[email-masked]>"
| 
| "Baer, Klaus <[email-masked]>"
| 
| ("utf" "[email-masked]")   <-- BAD (working on undecoded string)
| 
| (nil "Baer")                 <-- BAD (working on decoded string)
| (nil "Baer")

Unfortunately, such RFC2047 encoded addresses are very common in Germany
so that e.g. BBDB (which works on the 'decoded' string) fails in very
much cases.

Enrico