emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/net/browse-url.el,v


From: Michael Cadilhac
Subject: [Emacs-diffs] Changes to emacs/lisp/net/browse-url.el,v
Date: Mon, 17 Sep 2007 15:59:41 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Michael Cadilhac <cadilhac>     07/09/17 15:59:41

Index: browse-url.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/net/browse-url.el,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -b -r1.62 -r1.63
--- browse-url.el       12 Sep 2007 11:48:22 -0000      1.62
+++ browse-url.el       17 Sep 2007 15:59:41 -0000      1.63
@@ -430,7 +430,7 @@
   :group 'browse-url)
 
 (defcustom browse-url-new-window-flag nil
-  "If non-nil, always open a new browser window with appropriate browsers.
+  "Non-nil means always open a new browser window with appropriate browsers.
 Passing an interactive argument to \\[browse-url], or specific browser
 commands reverses the effect of this variable.  Requires Netscape version
 1.1N or later or XMosaic version 2.5 or later if using those browsers."
@@ -619,14 +619,12 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; URL encoding
 
-(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))
+(defun browse-url-url-encode-chars (text chars)
+  "URL-encode the chars in TEXT that match CHARS.
+CHARS is a regexp-like character alternative (e.g., \"[,)$]\")."
+  (let ((encoded-url (copy-sequence url))
        (s 0))
-    (while (setq s (string-match conf-char encoded-url s))
+    (while (setq s (string-match chars encoded-url s))
       (setq encoded-url
            (replace-match (format "%%%x"
                                   (string-to-char (match-string 0 
encoded-url)))
@@ -634,6 +632,13 @@
            s (1+ s)))
     encoded-url))
 
+(defun browse-url-encode-url (url)
+  "Escape annoying characters in URL.
+The annoying characters are those that can mislead a webbrowser
+regarding its parameter treatment.  For instance, `,' can
+be misleading because it could be used to separate URLs."
+  (browse-url-url-encode-chars url "[,)$]"))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; URL input
 
@@ -706,7 +711,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 'url-is-filename))
+  (setq file (browse-url-url-encode-chars file "[*\"()',=;?% ]"))
   (dolist (map browse-url-filename-alist)
     (when (and map (string-match (car map) file))
       (setq file (replace-match (cdr map) t nil file))))
@@ -1550,7 +1555,7 @@
                      "elinks" "-remote"
                      (concat "openURL(\"" url "\",new-tab)")))
       (otherwise
-       (error "Undefined exit-code of process `elinks'.")))))
+          (error "Undefined exit-code of process `elinks'")))))
 
 (provide 'browse-url)
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]