GNU bug report logs -
#7017
Suggestion: (url-retrieve-internal) hexify multibyte URL string first
Previous Next
Reported by: William Xu <william.xwl <at> gmail.com>
Date: Sun, 12 Sep 2010 01:03:02 UTC
Severity: normal
Tags: fixed, patch
Done: Chong Yidong <cyd <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Seth Mason <seth <at> edgecast.com> writes:
> If you put the following in a buffer and eval it, you'll get a 404:
>
> ;; http://httpbin.org/get?x=1
> ;; eval this buffer
> (url-retrieve (buffer-substring-no-properties 4 30) (lambda (&rest
> args) (switch-to-buffer (current-buffer))))
>
> If you curl/wget the same URL, it'll work fine.
>
> If you look at the request, it's going to "/get%3fx%3d1". It seems to me
> that the URL is getting improperly encoded for multibyte strings.
Thanks for pointing this out.
Applying url-hexify-string on the entire URL, as the previous patch did,
is wrong. We musn't hexify reserved characters that are being used in
their special role. Unfortunately, figuring out when those characters
are being used in their special role requires an implementation of
RFC2396, which I don't think we currently have in Emacs.
Or, the following not-strictly-correct hack leaves out reserved
characters from hexification.
=== modified file 'lisp/url/url.el'
*** lisp/url/url.el 2012-04-26 12:43:28 +0000
--- lisp/url/url.el 2012-05-08 04:46:45 +0000
***************
*** 180,188 ****
(url-gc-dead-buffers)
(if (stringp url)
(set-text-properties 0 (length url) nil url))
(when (multibyte-string-p url)
! (let ((url-unreserved-chars (append '(?: ?/) url-unreserved-chars)))
(setq url (url-hexify-string url))))
(if (not (vectorp url))
(setq url (url-generic-parse-url url)))
(if (not (functionp callback))
--- 180,193 ----
(url-gc-dead-buffers)
(if (stringp url)
(set-text-properties 0 (length url) nil url))
+
(when (multibyte-string-p url)
! (let* ((reserved-chars '(?! ?# ?$ ?& ?' ?( ?) ?* ?+ ?, ?/ ?: ?\;
! ?= ?? ?@ ?[ ?]))
! (url-unreserved-chars (append reserved-chars
! url-unreserved-chars)))
(setq url (url-hexify-string url))))
+
(if (not (vectorp url))
(setq url (url-generic-parse-url url)))
(if (not (functionp callback))
This bug report was last modified 13 years and 96 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.