summaryrefslogtreecommitdiff
path: root/lisp/files.el
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2008-03-01 01:28:31 +0000
committerMiles Bader <miles@gnu.org>2008-03-01 01:28:31 +0000
commit51fb064bc72968e739e8dea580e58796c1a87f4c (patch)
tree80c29b96dbb547a7c8db57a6d57ae4c6d2bfc1ca /lisp/files.el
parent14e8de0c3f87a228c05902be66c5bcf953636611 (diff)
parent613f60eeb171e5ad881f52d9e7c0ffce2e182fcb (diff)
downloademacs-51fb064bc72968e739e8dea580e58796c1a87f4c.tar.gz
Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1090
Diffstat (limited to 'lisp/files.el')
-rw-r--r--lisp/files.el17
1 files changed, 10 insertions, 7 deletions
diff --git a/lisp/files.el b/lisp/files.el
index d1b8cd2f30e..740bba2764a 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4656,15 +4656,18 @@ See also `auto-save-file-name-p'."
(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.