unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#6252: Emacs does not implement URL (aka "percent") decoding correctly.
@ 2010-05-22 23:46 José A. Romero L.
  2010-05-24  3:33 ` YAMAMOTO Mitsuharu
  2011-09-21 20:17 ` Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 10+ messages in thread
From: José A. Romero L. @ 2010-05-22 23:46 UTC (permalink / raw)
  To: 6252

On May 18, 20:14, Xah Lee <xah...@gmail.com>  wrote:

> is there emacs lisp function that decode the url percent encoding?
> e.g.http://en.wikipedia.org/wiki/Sylvester%E2%80%93Gallai_theorem
> should become
> http://en.wikipedia.org/wiki/Sylvester–Gallai_theorem
> that's a EN DASH (unicode 8211, #o20023, #x2013).
> I know there's a
>   (require 'gnus-util)
>  gnus-url-unhex-string
> but that just unhex, and generate gibberish if the url contain unicode
> chars.
(...)

Seems that RFC 3986 has not been implemented correctly in Emacs. IMHO
that is an important hole you have found there. The standard requires
that all unreserved characters be encoded/decoded as UTF8 bytes. Even
though the encoding part looks OK (in url-util.el), the decoding does
not go that last mile to interpret the decoded bytes as UTF-8.

Until a proper implementation is  done, I guess you could work around
the problem with something like this:

    (decode-coding-string
     (apply 'unibyte-string
            (string-to-list
             (url-unhex-string "http://en.wikipedia.org/wiki/Sylvester
%E2%80%93Gallai_theorem")))
     'utf-8)

(yes, it's ugly as hell but hey, it's free ;])

I've just sent this very message as a bug report to the Emacs team.

Cheers,
-- 
José A. Romero L.
escherdragon@gmail.com
"We who cut mere stones must always be envisioning cathedrals."
(Quarry worker's creed)





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-04-10  2:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-22 23:46 bug#6252: Emacs does not implement URL (aka "percent") decoding correctly José A. Romero L.
2010-05-24  3:33 ` YAMAMOTO Mitsuharu
     [not found]   ` <AANLkTilUODUArElMVd6FzgL08u1TmCVw2kar1Gf9z1Z9@mail.gmail.com>
2010-05-25  8:56     ` bug#6252: Fwd: " José A. Romero L.
2011-09-21 20:17 ` Lars Magne Ingebrigtsen
     [not found]   ` <CAJ_WfoU_JAjf-cTruu3fL1OO5fSMRHsjmnB=-aUK6h6RM7e8AA@mail.gmail.com>
2011-09-22  7:38     ` Lars Magne Ingebrigtsen
     [not found]       ` <CAJ_WfoV04Bis9msxHYLdu5VTONZ7hO_LsKy097MqfnmLf4kfjQ@mail.gmail.com>
2011-09-23  8:34         ` Lars Magne Ingebrigtsen
2011-09-23 11:12           ` José A. Romero L.
2011-09-25 22:16             ` Lars Magne Ingebrigtsen
2011-09-25 22:25               ` José A. Romero L.
2012-04-10  2:14               ` Lars Magne Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).