]> git.eshelyaron.com Git - emacs.git/commitdiff
Tramp: Fix file name quoting on MS Windows
authorMichael Albinus <michael.albinus@gmx.de>
Fri, 7 May 2021 15:25:49 +0000 (17:25 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Fri, 7 May 2021 15:25:49 +0000 (17:25 +0200)
* lisp/net/tramp-sh.el (tramp-make-copy-program-file-name):
Use `tramp-unquote-shell-quote-argument'.

* lisp/net/tramp.el (tramp-unquote-shell-quote-argument):
Adapt for MS Windows.

* test/lisp/net/tramp-tests.el (tramp--test-special-characters):
Adapt for MS Windows.

lisp/net/tramp-sh.el
lisp/net/tramp.el
test/lisp/net/tramp-tests.el

index 3ce74a2cf1a056a7207e12cc78bdaddd86176400..60090d31b88bab6e94a74f7140650479216d1757 100644 (file)
@@ -5266,7 +5266,7 @@ Return ATTR."
     ;; to be quoted.  OpenSSH 8 supports disabling of strict file name
     ;; checking in scp, we use it when available.
     (unless (string-match-p "ftp$" method)
-      (setq localname (shell-quote-argument localname)))
+      (setq localname (tramp-unquote-shell-quote-argument localname)))
     (cond
      ((tramp-get-method-parameter vec 'tramp-remote-copy-program)
       localname)
index 9fec151422140637a022026cd9ce60ce087c3605..5d62a1fb3d1fceadca6185f6aae37c145ed5bf80 100644 (file)
@@ -5476,8 +5476,12 @@ T1 and T2 are time values (as returned by `current-time' for example)."
   "Remove quotation prefix \"/:\" from string S, and quote it then for shell.
 Suppress `shell-file-name'.  This is needed on w32 systems, which
 would use a wrong quoting for local file names.  See `w32-shell-name'."
-  (let (shell-file-name)
-    (shell-quote-argument (tramp-compat-file-name-unquote s))))
+  (if (eq system-type 'windows-nt)
+      (let ((result (tramp-compat-file-name-unquote s)))
+       (setq result (tramp-compat-string-replace "\"" "\"\"" result))
+       (concat "\"" result "\""))
+    (let (shell-file-name)
+      (shell-quote-argument (tramp-compat-file-name-unquote s)))))
 
 ;; Currently (as of Emacs 20.5), the function `shell-quote-argument'
 ;; does not deal well with newline characters.  Newline is replaced by
index 0f6f3b798004e0c62762f28d7e826d838b023f6d..03915d7a3fc3b30fcc21832696ce9611cdfe6400 100644 (file)
@@ -5882,6 +5882,7 @@ This requires restrictions of file name syntax."
            (make-directory tmp-name2)
 
            (dolist (elt files)
+             ;(tramp--test-message "%s" elt)
              (let* ((file1 (expand-file-name elt tmp-name1))
                     (file2 (expand-file-name elt tmp-name2))
                     (file3 (expand-file-name (concat elt "foo") tmp-name1)))
@@ -6071,7 +6072,8 @@ This requires restrictions of file name syntax."
                 "\tfoo bar baz\t")
                (t " foo\tbar baz\t"))
          "@foo@bar@baz@"
-         "$foo$bar$$baz$"
+         (unless (tramp--test-windows-nt-and-scp-p)
+           "$foo$bar$$baz$")
          "-foo-bar-baz-"
          "%foo%bar%baz%"
          "&foo&bar&baz&"
@@ -6087,9 +6089,10 @@ This requires restrictions of file name syntax."
              "'foo'bar'baz'"
            "'foo\"bar'baz\"")
          "#foo~bar#baz~"
-         (if (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p))
-             "!foo!bar!baz!"
-           "!foo|bar!baz|")
+         (unless (tramp--test-windows-nt-and-scp-p)
+           (if (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p))
+               "!foo!bar!baz!"
+             "!foo|bar!baz|"))
          (if (or (tramp--test-gvfs-p)
                  (tramp--test-rclone-p)
                  (tramp--test-windows-nt-or-smb-p))
@@ -6110,7 +6113,6 @@ This requires restrictions of file name syntax."
   "Check special characters in file names."
   (skip-unless (tramp--test-enabled))
   (skip-unless (not (tramp--test-rsync-p)))
-;  (skip-unless (not (tramp--test-windows-nt-and-scp-p)))
   (skip-unless (or (tramp--test-emacs26-p) (not (tramp--test-rclone-p))))
 
   (tramp--test-special-characters))
@@ -6122,7 +6124,6 @@ Use the `stat' command."
   (skip-unless (tramp--test-enabled))
   (skip-unless (tramp--test-sh-p))
   (skip-unless (not (tramp--test-rsync-p)))
-;  (skip-unless (not (tramp--test-windows-nt-and-scp-p)))
   ;; We cannot use `tramp-test-vec', because this fails during compilation.
   (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
     (skip-unless (tramp-get-remote-stat v)))
@@ -6141,7 +6142,6 @@ Use the `perl' command."
   (skip-unless (tramp--test-enabled))
   (skip-unless (tramp--test-sh-p))
   (skip-unless (not (tramp--test-rsync-p)))
-;  (skip-unless (not (tramp--test-windows-nt-and-scp-p)))
   ;; We cannot use `tramp-test-vec', because this fails during compilation.
   (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
     (skip-unless (tramp-get-remote-perl v)))
@@ -6163,7 +6163,6 @@ Use the `ls' command."
   (skip-unless (tramp--test-enabled))
   (skip-unless (tramp--test-sh-p))
   (skip-unless (not (tramp--test-rsync-p)))
-;  (skip-unless (not (tramp--test-windows-nt-and-scp-p)))
 
   (let ((tramp-connection-properties
         (append