1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Fix Bug#29579

* lisp/files.el (file-name-non-special):
Inhibit `file-name-handler-alist' only for some operations.
Add missing operations.  (Bug#29579)

* lisp/net/tramp-compat.el (tramp-compat-file-name-quote):
Do not quote if it is quoted already.

* lisp/net/tramp-smb.el (tramp-smb-handle-insert-directory):
Use `copy-tree' but `copy-sequence'.

* lisp/net/tramp.el (tramp-handle-file-truename): Handle several
trailing slashes correctly.

* test/lisp/net/tramp-tests.el (tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test24-file-acl)
(tramp-test25-file-selinux, tramp--test-check-files):
Handle also quoted file names.
(tramp-test21-file-links): Fix file name quoting test.
(tramp-test24-file-acl): Be more robust for "smb" method.
(tramp-test35-make-auto-save-file-name): Enable hidden test cases.
This commit is contained in:
Michael Albinus 2017-12-06 20:49:30 +01:00
parent cb3d979b74
commit a1bbc49015
6 changed files with 97 additions and 86 deletions

View file

@ -6975,60 +6975,67 @@ only these files will be asked to be saved."
;; We depend on being the last handler on the list,
;; so that anything else which does need handling
;; has been handled already.
;; So it is safe for us to inhibit *all* magic file name handlers.
;; So it is safe for us to inhibit *all* magic file name handlers for
;; operations, which return a file name. See Bug#29579.
(defun file-name-non-special (operation &rest arguments)
(let ((file-name-handler-alist nil)
(default-directory
;; Some operations respect file name handlers in
;; `default-directory'. Because core function like
;; `call-process' don't care about file name handlers in
;; `default-directory', we here have to resolve the
;; directory into a local one. For `process-file',
;; `start-file-process', and `shell-command', this fixes
;; Bug#25949.
(if (memq operation '(insert-directory process-file start-file-process
shell-command))
(directory-file-name
(expand-file-name
(unhandled-file-name-directory default-directory)))
default-directory))
;; Get a list of the indices of the args which are file names.
(file-arg-indices
(cdr (or (assq operation
;; The first six are special because they
;; return a file name. We want to include the /:
;; in the return value.
;; So just avoid stripping it in the first place.
'((expand-file-name . nil)
(file-name-directory . nil)
(file-name-as-directory . nil)
(directory-file-name . nil)
(file-name-sans-versions . nil)
(find-backup-file-name . nil)
;; `identity' means just return the first arg
;; not stripped of its quoting.
(substitute-in-file-name identity)
;; `add' means add "/:" to the result.
(file-truename add 0)
(insert-file-contents insert-file-contents 0)
;; `unquote-then-quote' means set buffer-file-name
;; temporarily to unquoted filename.
(verify-visited-file-modtime unquote-then-quote)
;; List the arguments which are filenames.
(file-name-completion 1)
(file-name-all-completions 1)
(write-region 2 5)
(rename-file 0 1)
(copy-file 0 1)
(make-symbolic-link 0 1)
(add-name-to-file 0 1)))
;; For all other operations, treat the first argument only
;; as the file name.
'(nil 0))))
method
;; Copy ARGUMENTS so we can replace elements in it.
(arguments (copy-sequence arguments)))
(let* ((op-returns-file-name-list
'(expand-file-name file-name-directory file-name-as-directory
directory-file-name file-name-sans-versions
find-backup-file-name file-remote-p))
(file-name-handler-alist
(and
(not (memq operation op-returns-file-name-list))
file-name-handler-alist))
(default-directory
;; Some operations respect file name handlers in
;; `default-directory'. Because core function like
;; `call-process' don't care about file name handlers in
;; `default-directory', we here have to resolve the
;; directory into a local one. For `process-file',
;; `start-file-process', and `shell-command', this fixes
;; Bug#25949.
(if (memq operation
'(insert-directory process-file start-file-process
shell-command))
(directory-file-name
(expand-file-name
(unhandled-file-name-directory default-directory)))
default-directory))
;; Get a list of the indices of the args which are file names.
(file-arg-indices
(cdr (or (assq operation
;; The first seven are special because they
;; return a file name. We want to include the /:
;; in the return value.
;; So just avoid stripping it in the first place.
(append
(mapcar 'list op-returns-file-name-list)
'(;; `identity' means just return the first arg
;; not stripped of its quoting.
(substitute-in-file-name identity)
;; `add' means add "/:" to the result.
(file-truename add 0)
(insert-file-contents insert-file-contents 0)
;; `unquote-then-quote' means set buffer-file-name
;; temporarily to unquoted filename.
(verify-visited-file-modtime unquote-then-quote)
;; List the arguments which are filenames.
(file-name-completion 1)
(file-name-all-completions 1)
(write-region 2 5)
(rename-file 0 1)
(copy-file 0 1)
(copy-directory 0 1)
(file-in-directory-p 0 1)
(make-symbolic-link 0 1)
(add-name-to-file 0 1))))
;; For all other operations, treat the first argument only
;; as the file name.
'(nil 0))))
method
;; Copy ARGUMENTS so we can replace elements in it.
(arguments (copy-sequence arguments)))
(if (symbolp (car file-arg-indices))
(setq method (pop file-arg-indices)))
;; Strip off the /: from the file names that have it.