Mercurial > emacs
changeset 54803:a78c94aa182d
(url-hexify-string): Don't give multibyte error for char <16.
(mail-header-extract): Autoload.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 12 Apr 2004 04:06:01 +0000 |
parents | 15a07e792605 |
children | 2f011866477f |
files | lisp/url/url-util.el |
diffstat | 1 files changed, 24 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/url/url-util.el Mon Apr 12 04:05:50 2004 +0000 +++ b/lisp/url/url-util.el Mon Apr 12 04:06:01 2004 +0000 @@ -27,6 +27,7 @@ (require 'url-parse) (autoload 'timezone-parse-date "timezone") (autoload 'timezone-make-date-arpa-standard "timezone") +(autoload 'mail-header-extract "mailheader") (defvar url-parse-args-syntax-table (copy-syntax-table emacs-lisp-mode-syntax-table) @@ -292,9 +293,28 @@ (+ 10 (- x ?A))) (- x ?0))) +;; Fixme: Is this definition better, and does it ever matter? + +;; (defun url-unhex-string (str &optional allow-newlines) +;; "Remove %XX, embedded spaces, etc in a url. +;; If optional second argument ALLOW-NEWLINES is non-nil, then allow the +;; decoding of carriage returns and line feeds in the string, which is normally +;; forbidden in URL encoding." +;; (setq str (or str "")) +;; (setq str (replace-regexp-in-string "%[[:xdigit:]]\\{2\\}" +;; (lambda (match) +;; (string (string-to-number +;; (substring match 1) 16))) +;; str t t)) +;; (if allow-newlines +;; (replace-regexp-in-string "[\n\r]" (lambda (match) +;; (format "%%%.2X" (aref match 0))) +;; str t t) +;; str)) + ;;;###autoload (defun url-unhex-string (str &optional allow-newlines) - "Remove %XXX embedded spaces, etc in a url. + "Remove %XX embedded spaces, etc in a url. If optional second argument ALLOW-NEWLINES is non-nil, then allow the decoding of carriage returns and line feeds in the string, which is normally forbidden in URL encoding." @@ -334,11 +354,9 @@ (lambda (char) ;; Fixme: use a char table instead. (if (not (memq char url-unreserved-chars)) - (if (< char 16) - (format "%%0%X" char) - (if (> char 255) - (error "Hexifying multibyte character %s" str)) - (format "%%%X" char)) + (if (> char 255) + (error "Hexifying multibyte character %s" str) + (format "%%%02X" char)) (char-to-string char))) str ""))