--- browse-url.el 12 Sep 2007 10:49:04 +0200 1.61 +++ browse-url.el 12 Sep 2007 11:09:27 +0200 @@ -619,12 +619,16 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 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 chars &optional encode-percent) + "Encode all `confusing' characters denoted by the regexp CHARS in URL. +If ENCODE-PERCENT is non-nil, consider `%' as a confusing char." + (let ((s 0) + (encoded-url (copy-sequence url))) + (when encode-percent + (while (setq s (string-match "%" encoded-url s)) + (setq encoded-url (replace-match "%25" t t encoded-url) + s (1+ s)))) + (while (string-match chars encoded-url) (setq encoded-url (replace-match (format "%%%x" (string-to-char (match-string 0 encoded-url))) @@ -703,7 +707,7 @@ (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 "[*\"()',=;? ]" 'encode-percent)) (dolist (map browse-url-filename-alist) (when (and map (string-match (car map) file)) (setq file (replace-match (cdr map) t nil file)))) @@ -909,7 +913,7 @@ When called non-interactively, optional second argument NEW-WINDOW is used instead of `browse-url-new-window-flag'." (interactive (browse-url-interactive-arg "URL: ")) - (setq url (browse-url-encode-url url)) + (setq url (browse-url-encode-url url "[,)$]")) (let* ((process-environment (browse-url-process-environment)) (process (apply 'start-process @@ -979,7 +983,7 @@ When called non-interactively, optional second argument NEW-WINDOW is used instead of `browse-url-new-window-flag'." (interactive (browse-url-interactive-arg "URL: ")) - (setq url (browse-url-encode-url url)) + (setq url (browse-url-encode-url url "[,)$]")) (let* ((process-environment (browse-url-process-environment)) (process (apply 'start-process @@ -1037,7 +1041,7 @@ are ignored as well. Firefox on Windows will always open the requested URL in a new window." (interactive (browse-url-interactive-arg "URL: ")) - (setq url (browse-url-encode-url url)) + (setq url (browse-url-encode-url url "[,)$]")) (let* ((process-environment (browse-url-process-environment)) (process (apply 'start-process @@ -1089,7 +1093,7 @@ When called non-interactively, optional second argument NEW-WINDOW is used instead of `browse-url-new-window-flag'." (interactive (browse-url-interactive-arg "URL: ")) - (setq url (browse-url-encode-url url)) + (setq url (browse-url-encode-url url "[,)$]")) (let* ((process-environment (browse-url-process-environment)) (process (apply 'start-process (concat "galeon " url) @@ -1134,7 +1138,7 @@ When called non-interactively, optional second argument NEW-WINDOW is used instead of `browse-url-new-window-flag'." (interactive (browse-url-interactive-arg "URL: ")) - (setq url (browse-url-encode-url url)) + (setq url (browse-url-encode-url url "[,)$]")) (let* ((process-environment (browse-url-process-environment)) (process (apply 'start-process (concat "epiphany " url) @@ -1520,7 +1524,7 @@ The Elinks command will be prepended by the program+arguments from `elinks-browse-url-wrapper'." (interactive (browse-url-interactive-arg "URL: ")) - (setq url (browse-url-encode-url url)) + (setq url (browse-url-encode-url url "[,)$]")) (let ((process-environment (browse-url-process-environment)) (elinks-ping-process (start-process "elinks-ping" nil "elinks" "-remote" "ping()")))