# HG changeset patch # User Stefan Monnier # Date 1081742761 0 # Node ID a78c94aa182d5cd9c87ae000f60687835381ad9a # Parent 15a07e79260501ca4eaba6f1dea6c76bff5db84d (url-hexify-string): Don't give multibyte error for char <16. (mail-header-extract): Autoload. diff -r 15a07e792605 -r a78c94aa182d lisp/url/url-util.el --- 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 ""))