diff options
| author | Michaël Cadilhac | 2007-09-12 11:48:34 +0000 |
|---|---|---|
| committer | Michaël Cadilhac | 2007-09-12 11:48:34 +0000 |
| commit | ad56e18b1f3ec045f32d44f558c13ae44d94cca6 (patch) | |
| tree | b104af2e20642bf164b015f1f903f5179bf3ce21 | |
| parent | 11b9f7a3c48f25a0e0d1e4b14a5362e071b08b01 (diff) | |
| download | emacs-ad56e18b1f3ec045f32d44f558c13ae44d94cca6.tar.gz emacs-ad56e18b1f3ec045f32d44f558c13ae44d94cca6.zip | |
(browse-url-encode-url): Fix an infinite loop.
New argument `filename-p' to use one set of confusing chars or another.
(browse-url-file-url): Use the argument.
Suggested by Johannes Weiner.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/net/browse-url.el | 19 |
2 files changed, 18 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f1cfd7a03ea..c53e17cce31 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2007-09-12 Micha,Ak(Bl Cadilhac <michael@cadilhac.name> | ||
| 2 | |||
| 3 | * lisp/net/browse-url.el (browse-url-encode-url): Fix an infinite loop. | ||
| 4 | New argument `filename-p' to use one set of confusing chars or another. | ||
| 5 | (browse-url-file-url): Use the argument. | ||
| 6 | Suggested by Johannes Weiner. | ||
| 7 | |||
| 1 | 2007-09-12 Romain Francoise <romain@orebokech.com> | 8 | 2007-09-12 Romain Francoise <romain@orebokech.com> |
| 2 | 9 | ||
| 3 | * cus-start.el (all): Revert 2007-09-08 change. | 10 | * cus-start.el (all): Revert 2007-09-08 change. |
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el index d152f202561..936ca2d4222 100644 --- a/lisp/net/browse-url.el +++ b/lisp/net/browse-url.el | |||
| @@ -619,16 +619,19 @@ down (this *won't* always work)." | |||
| 619 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 619 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 620 | ;; URL encoding | 620 | ;; URL encoding |
| 621 | 621 | ||
| 622 | (defun browse-url-encode-url (url) | 622 | (defun browse-url-encode-url (url &optional filename-p) |
| 623 | "Encode all `confusing' characters in URL." | 623 | "Encode all `confusing' characters in URL. |
| 624 | (let ((encoded-url (copy-sequence url))) | 624 | If FILENAME-P is nil, the confusing characters are [,)$]. |
| 625 | (while (string-match "%" encoded-url) | 625 | Otherwise, the confusing characters are [*\"()',=;?% ]." |
| 626 | (setq encoded-url (replace-match "%25" t t encoded-url))) | 626 | (let ((conf-char (if filename-p "[*\"()',=;?% ]" "[,)$]")) |
| 627 | (while (string-match "[*\"()',=;? ]" encoded-url) | 627 | (encoded-url (copy-sequence url)) |
| 628 | (s 0)) | ||
| 629 | (while (setq s (string-match conf-char encoded-url s)) | ||
| 628 | (setq encoded-url | 630 | (setq encoded-url |
| 629 | (replace-match (format "%%%x" | 631 | (replace-match (format "%%%x" |
| 630 | (string-to-char (match-string 0 encoded-url))) | 632 | (string-to-char (match-string 0 encoded-url))) |
| 631 | t t encoded-url))) | 633 | t t encoded-url) |
| 634 | s (1+ s))) | ||
| 632 | encoded-url)) | 635 | encoded-url)) |
| 633 | 636 | ||
| 634 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 637 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| @@ -703,7 +706,7 @@ Use variable `browse-url-filename-alist' to map filenames to URLs." | |||
| 703 | (or file-name-coding-system | 706 | (or file-name-coding-system |
| 704 | default-file-name-coding-system)))) | 707 | default-file-name-coding-system)))) |
| 705 | (if coding (setq file (encode-coding-string file coding)))) | 708 | (if coding (setq file (encode-coding-string file coding)))) |
| 706 | (setq file (browse-url-encode-url file)) | 709 | (setq file (browse-url-encode-url file 'url-is-filename)) |
| 707 | (dolist (map browse-url-filename-alist) | 710 | (dolist (map browse-url-filename-alist) |
| 708 | (when (and map (string-match (car map) file)) | 711 | (when (and map (string-match (car map) file)) |
| 709 | (setq file (replace-match (cdr map) t nil file)))) | 712 | (setq file (replace-match (cdr map) t nil file)))) |