diff options
| author | Stefan Monnier | 2004-04-12 04:06:01 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2004-04-12 04:06:01 +0000 |
| commit | c6bfe6e7caa64bca676230a5d1b285f3c3654d37 (patch) | |
| tree | 5727e1ed33e6a1d7091e6ff0025d2da0325abf84 | |
| parent | 61bbdf64e85f2713eb145a639ddcc57aea28e08a (diff) | |
| download | emacs-c6bfe6e7caa64bca676230a5d1b285f3c3654d37.tar.gz emacs-c6bfe6e7caa64bca676230a5d1b285f3c3654d37.zip | |
(url-hexify-string): Don't give multibyte error for char <16.
(mail-header-extract): Autoload.
| -rw-r--r-- | lisp/url/url-util.el | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/lisp/url/url-util.el b/lisp/url/url-util.el index 1472febd05c..49e805086fb 100644 --- a/lisp/url/url-util.el +++ b/lisp/url/url-util.el | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | (require 'url-parse) | 27 | (require 'url-parse) |
| 28 | (autoload 'timezone-parse-date "timezone") | 28 | (autoload 'timezone-parse-date "timezone") |
| 29 | (autoload 'timezone-make-date-arpa-standard "timezone") | 29 | (autoload 'timezone-make-date-arpa-standard "timezone") |
| 30 | (autoload 'mail-header-extract "mailheader") | ||
| 30 | 31 | ||
| 31 | (defvar url-parse-args-syntax-table | 32 | (defvar url-parse-args-syntax-table |
| 32 | (copy-syntax-table emacs-lisp-mode-syntax-table) | 33 | (copy-syntax-table emacs-lisp-mode-syntax-table) |
| @@ -292,9 +293,28 @@ Will not do anything if url-show-status is nil." | |||
| 292 | (+ 10 (- x ?A))) | 293 | (+ 10 (- x ?A))) |
| 293 | (- x ?0))) | 294 | (- x ?0))) |
| 294 | 295 | ||
| 296 | ;; Fixme: Is this definition better, and does it ever matter? | ||
| 297 | |||
| 298 | ;; (defun url-unhex-string (str &optional allow-newlines) | ||
| 299 | ;; "Remove %XX, embedded spaces, etc in a url. | ||
| 300 | ;; If optional second argument ALLOW-NEWLINES is non-nil, then allow the | ||
| 301 | ;; decoding of carriage returns and line feeds in the string, which is normally | ||
| 302 | ;; forbidden in URL encoding." | ||
| 303 | ;; (setq str (or str "")) | ||
| 304 | ;; (setq str (replace-regexp-in-string "%[[:xdigit:]]\\{2\\}" | ||
| 305 | ;; (lambda (match) | ||
| 306 | ;; (string (string-to-number | ||
| 307 | ;; (substring match 1) 16))) | ||
| 308 | ;; str t t)) | ||
| 309 | ;; (if allow-newlines | ||
| 310 | ;; (replace-regexp-in-string "[\n\r]" (lambda (match) | ||
| 311 | ;; (format "%%%.2X" (aref match 0))) | ||
| 312 | ;; str t t) | ||
| 313 | ;; str)) | ||
| 314 | |||
| 295 | ;;;###autoload | 315 | ;;;###autoload |
| 296 | (defun url-unhex-string (str &optional allow-newlines) | 316 | (defun url-unhex-string (str &optional allow-newlines) |
| 297 | "Remove %XXX embedded spaces, etc in a url. | 317 | "Remove %XX embedded spaces, etc in a url. |
| 298 | If optional second argument ALLOW-NEWLINES is non-nil, then allow the | 318 | If optional second argument ALLOW-NEWLINES is non-nil, then allow the |
| 299 | decoding of carriage returns and line feeds in the string, which is normally | 319 | decoding of carriage returns and line feeds in the string, which is normally |
| 300 | forbidden in URL encoding." | 320 | forbidden in URL encoding." |
| @@ -334,11 +354,9 @@ This is taken from RFC 2396.") | |||
| 334 | (lambda (char) | 354 | (lambda (char) |
| 335 | ;; Fixme: use a char table instead. | 355 | ;; Fixme: use a char table instead. |
| 336 | (if (not (memq char url-unreserved-chars)) | 356 | (if (not (memq char url-unreserved-chars)) |
| 337 | (if (< char 16) | 357 | (if (> char 255) |
| 338 | (format "%%0%X" char) | 358 | (error "Hexifying multibyte character %s" str) |
| 339 | (if (> char 255) | 359 | (format "%%%02X" char)) |
| 340 | (error "Hexifying multibyte character %s" str)) | ||
| 341 | (format "%%%X" char)) | ||
| 342 | (char-to-string char))) | 360 | (char-to-string char))) |
| 343 | str "")) | 361 | str "")) |
| 344 | 362 | ||