From f06915c93c0755a708f9c600e90674c68b5326dc Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Wed, 9 Feb 2022 17:02:29 +0100 Subject: [PATCH] Tilde expansion is not possible for Tramp sshfs method * lisp/net/tramp.el (tramp-handle-expand-file-name): Tilde expansion is not possible. (Bug#53847) --- lisp/net/tramp.el | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 05a80e1dcf5..1b5de460160 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -3474,19 +3474,19 @@ User is always nil." (with-parsed-tramp-file-name name nil (unless (tramp-run-real-handler #'file-name-absolute-p (list localname)) (setq localname (concat "/" localname))) + ;; Tilde expansion is not possible. + (when (string-match-p "\\`\\(~[^/]*\\)\\(.*\\)\\'" localname) + (tramp-error v 'file-error "Cannot expand tilde in file `%s'" name)) ;; Do not keep "/..". (when (string-match-p "^/\\.\\.?$" localname) (setq localname "/")) - ;; Do normal `expand-file-name' (this does "/./" and "/../"), - ;; unless there are tilde characters in file name. + ;; Do normal `expand-file-name' (this does "/./" and "/../"). ;; `default-directory' is bound, because on Windows there would ;; be problems with UNC shares or Cygwin mounts. (let ((default-directory tramp-compat-temporary-file-directory)) (tramp-make-tramp-file-name - v (if (string-match-p "\\`~" localname) - localname - (tramp-drop-volume-letter - (tramp-run-real-handler #'expand-file-name (list localname))))))))) + v (tramp-drop-volume-letter + (tramp-run-real-handler #'expand-file-name (list localname)))))))) (defun tramp-handle-file-accessible-directory-p (filename) "Like `file-accessible-directory-p' for Tramp files." -- 2.39.5