emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lisp/files.el,v [EMACS_22_BASE]


From: Jason Rumney
Subject: [Emacs-diffs] Changes to emacs/lisp/files.el,v [EMACS_22_BASE]
Date: Tue, 26 Feb 2008 16:52:04 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Branch:         EMACS_22_BASE
Changes by:     Jason Rumney <jasonr>   08/02/26 16:52:03

Index: files.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/files.el,v
retrieving revision 1.896.2.39
retrieving revision 1.896.2.40
diff -u -b -r1.896.2.39 -r1.896.2.40
--- files.el    25 Feb 2008 17:40:42 -0000      1.896.2.39
+++ files.el    26 Feb 2008 16:52:02 -0000      1.896.2.40
@@ -4561,15 +4561,18 @@
     (let ((buffer-name (buffer-name))
          (limit 0)
          file-name)
-      ;; Eliminate all slashes and backslashes by
-      ;; replacing them with sequences that start with %.
-      ;; Quote % also, to keep distinct names distinct.
-      (while (string-match "[/\\%]" buffer-name limit)
+      ;; Restrict the characters used in the file name to those which
+      ;; are known to be safe on all filesystems, url-encoding the
+      ;; rest.
+      ;; We do this on all platforms, because even if we are not
+      ;; running on DOS/Windows, the current directory may be on a
+      ;; mounted VFAT filesystem, such as a USB memory stick.
+      (while (string-match "[^A-Za-z0-9-_.~#+]" buffer-name limit)
        (let* ((character (aref buffer-name (match-beginning 0)))
               (replacement
-               (cond ((eq character ?%) "%%")
-                     ((eq character ?/) "%+")
-                     ((eq character ?\\) "%-"))))
+                ;; For multibyte characters, this will produce more than
+                ;; 2 hex digits, so is not true URL encoding.
+                (format "%%%02X" character)))
          (setq buffer-name (replace-match replacement t t buffer-name))
          (setq limit (1+ (match-end 0)))))
       ;; Generate the file name.




reply via email to

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