summaryrefslogtreecommitdiff
path: root/lisp/net/browse-url.el
diff options
context:
space:
mode:
authorMichaël Cadilhac <michael.cadilhac@lrde.org>2007-09-12 11:48:34 +0000
committerMichaël Cadilhac <michael.cadilhac@lrde.org>2007-09-12 11:48:34 +0000
commitad56e18b1f3ec045f32d44f558c13ae44d94cca6 (patch)
treeb104af2e20642bf164b015f1f903f5179bf3ce21 /lisp/net/browse-url.el
parent11b9f7a3c48f25a0e0d1e4b14a5362e071b08b01 (diff)
downloademacs-ad56e18b1f3ec045f32d44f558c13ae44d94cca6.tar.gz
(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.
Diffstat (limited to 'lisp/net/browse-url.el')
-rw-r--r--lisp/net/browse-url.el19
1 files changed, 11 insertions, 8 deletions
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)."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; URL encoding
-(defun browse-url-encode-url (url)
- "Encode all `confusing' characters in URL."
- (let ((encoded-url (copy-sequence url)))
- (while (string-match "%" encoded-url)
- (setq encoded-url (replace-match "%25" t t encoded-url)))
- (while (string-match "[*\"()',=;? ]" encoded-url)
+(defun browse-url-encode-url (url &optional filename-p)
+ "Encode all `confusing' characters in URL.
+If FILENAME-P is nil, the confusing characters are [,)$].
+Otherwise, the confusing characters are [*\"()',=;?% ]."
+ (let ((conf-char (if filename-p "[*\"()',=;?% ]" "[,)$]"))
+ (encoded-url (copy-sequence url))
+ (s 0))
+ (while (setq s (string-match conf-char encoded-url s))
(setq encoded-url
(replace-match (format "%%%x"
(string-to-char (match-string 0 encoded-url)))
- t t encoded-url)))
+ t t encoded-url)
+ s (1+ s)))
encoded-url))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -703,7 +706,7 @@ Use variable `browse-url-filename-alist' to map filenames to URLs."
(or file-name-coding-system
default-file-name-coding-system))))
(if coding (setq file (encode-coding-string file coding))))
- (setq file (browse-url-encode-url file))
+ (setq file (browse-url-encode-url file 'url-is-filename))
(dolist (map browse-url-filename-alist)
(when (and map (string-match (car map) file))
(setq file (replace-match (cdr map) t nil file))))