emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 9457d4f: Tramp: Fix file name quoting on MS Windows


From: Michael Albinus
Subject: master 9457d4f: Tramp: Fix file name quoting on MS Windows
Date: Fri, 7 May 2021 11:25:57 -0400 (EDT)

branch: master
commit 9457d4f20f1f3da8450924cfe1f776fdd04261bb
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    Tramp: Fix file name quoting on MS Windows
    
    * 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         |  2 +-
 lisp/net/tramp.el            |  8 ++++++--
 test/lisp/net/tramp-tests.el | 15 +++++++--------
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 3ce74a2..60090d3 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -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)
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 9fec151..5d62a1f 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -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
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 0f6f3b7..03915d7 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]