Subject: bug#39689: 26.3; browse-url-mail not supporting RFC6068 (UTF-8-Based Percent-Encoding)

From: Robert Pluim <[email-masked]>
Date: Thu, 27 Feb 2020 16:08:25 +0100

>>>>> On Thu, 27 Feb 2020 11:51:35 +0100, Robert Pluim <[email-masked]> said:

>>>>> On Thu, 20 Feb 2020 14:48:54 +0100, Vegard Vesterheim via "Bug
    Robert> reports for GNU Emacs, the Swiss army knife of text editors"
    Robert> <[email-masked]> said:

    Vegard> Emacs does not seem to correctly handle UTF-8-Based Percent-Encoding as
    Vegard> illustrated in Chapter 6.2 from RFC6068.

    Vegard> The command 
    Vegard> emacs -Q -l browse-url -eval '(browse-url-mail "mailto:[email-masked]?subject=caf%C3%A9&body=caf%C3%A9")'

    Vegard> should result in a message buffer with the string "café" insterted into the
    Vegard> body part of the message. Instead the string "cafÃ©" is inserted.

    Robert> Yes, the assumption in rfc2368-unhexify-string is that percent
    Robert> escaping is being done of ASCII characters.

    Robert> epg--decode-percent-escape-as-utf-8 in epg.el does the
    Robert> right thing, it could be renamed and moved. I think rfc2047 decoding
    Robert> needs doing on the result as well. Lars, should I just stick these in
    Robert> rfc2368.el but named something like rfc6068-unhexify-string and
    Robert> rfc6068-decode-2047-string or something?

Oh, and thereʼs another version in gnus-util, and one in url, and an
almost compatible one in org [1]. The gnus and url ones suffer from
this same issue, although they both return different wrong results :-)

At least the epg, rfc2368, gnus, and the url versions look like they
can be unified. Not sure where to put them though.

Footnotes:
[1]  It supports % representation of the UTF-8 encoding of chars, but
     also of the unicode code point of chars, so eg %E1 gets turned
     into á. Iʼm sure thereʼs some historical reason for that.