diff options
author | Jason Rumney <jasonr@gnu.org> | 2008-02-26 16:52:02 +0000 |
---|---|---|
committer | Jason Rumney <jasonr@gnu.org> | 2008-02-26 16:52:02 +0000 |
commit | ad80c6792833c0f7c1f6e2e444026bd75dd2ff12 (patch) | |
tree | c47d76b673bfcc28088d17ad55158a9e4633b122 /lisp/files.el | |
parent | 6329325d6b89c0fb0cff60fc458dc08cfcdd85de (diff) | |
download | emacs-ad80c6792833c0f7c1f6e2e444026bd75dd2ff12.tar.gz |
(make-auto-save-file-name): Encode more characters in
non-file buffer names. Use url-encoding.
Diffstat (limited to 'lisp/files.el')
-rw-r--r-- | lisp/files.el | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lisp/files.el b/lisp/files.el index be98b3c8562..840ab2f77fa 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -4561,15 +4561,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. |