mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
Simplify url-encode-url and add a test
* lisp/url/url-util.el (url-encode-url): Simplify. url-generic-parse-url copes with multibyte strings just fine (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=24117#185). * test/lisp/url/url-parse-tests.el (url-generic-parse-url/multibyte-host-and-path): New test.
This commit is contained in:
parent
58326f0f11
commit
17e540aa42
2 changed files with 6 additions and 10 deletions
|
|
@ -450,13 +450,10 @@ This function also performs URI normalization, e.g. converting
|
|||
the scheme to lowercase if it is uppercase. Apart from
|
||||
normalization, if URL is already URI-encoded, this function
|
||||
should return it unchanged."
|
||||
(if (multibyte-string-p url)
|
||||
(setq url (encode-coding-string url 'utf-8)))
|
||||
(let* ((obj (url-generic-parse-url url))
|
||||
(user (url-user obj))
|
||||
(pass (url-password obj))
|
||||
(host (url-host obj))
|
||||
(path-and-query (url-path-and-query obj))
|
||||
(path-and-query (url-path-and-query obj))
|
||||
(path (car path-and-query))
|
||||
(query (cdr path-and-query))
|
||||
(frag (url-target obj)))
|
||||
|
|
@ -464,12 +461,6 @@ should return it unchanged."
|
|||
(setf (url-user obj) (url-hexify-string user)))
|
||||
(if pass
|
||||
(setf (url-password obj) (url-hexify-string pass)))
|
||||
;; No special encoding for IPv6 literals.
|
||||
(and host
|
||||
(not (string-match "\\`\\[.*\\]\\'" host))
|
||||
(setf (url-host obj)
|
||||
(decode-coding-string (url-host obj) 'utf-8)))
|
||||
|
||||
(if path
|
||||
(setq path (url-hexify-string path url-path-allowed-chars)))
|
||||
(if query
|
||||
|
|
|
|||
|
|
@ -162,6 +162,11 @@
|
|||
(should (equal (url-generic-parse-url "#") (url-parse-make-urlobj nil nil nil nil nil "" "" nil nil)))
|
||||
(should (equal (url-generic-parse-url "#foo") (url-parse-make-urlobj nil nil nil nil nil "" "foo" nil nil))))
|
||||
|
||||
(ert-deftest url-generic-parse-url/multibyte-host-and-path ()
|
||||
(should (equal (url-generic-parse-url "http://банки.рф/фыва/")
|
||||
(url-parse-make-urlobj "http" nil nil "банки.рф" nil
|
||||
"/фыва/" nil nil t))))
|
||||
|
||||
(provide 'url-parse-tests)
|
||||
|
||||
;;; url-parse-tests.el ends here
|
||||
|
|
|
|||
Loading…
Reference in a new issue