diff options
| author | Michael Albinus | 2022-06-09 14:44:00 +0200 |
|---|---|---|
| committer | Michael Albinus | 2022-06-09 14:44:00 +0200 |
| commit | 3fd08543782d0d417eaa2dda0727ea16b3271710 (patch) | |
| tree | 3bb6782c63652b57cbd865c040ae2811335d8481 | |
| parent | d02c94090c4dd7c90da9ccd3268a9e02cadf0a45 (diff) | |
| download | emacs-3fd08543782d0d417eaa2dda0727ea16b3271710.tar.gz emacs-3fd08543782d0d417eaa2dda0727ea16b3271710.zip | |
Fix file name quoting in tramp-smb.el (do not merge)
* lisp/net/tramp-smb.el (tramp-smb-handle-write-region): Quote tmpfile.
(tramp-smb-get-localname): Remove superfluous test. (Bug#55855)
* test/lisp/net/tramp-tests.el (tramp-test03-file-name-method-rules):
Remove superfluous checks.
| -rw-r--r-- | lisp/net/tramp-smb.el | 7 | ||||
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 12 |
2 files changed, 4 insertions, 15 deletions
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index 2aaa6e8ab3f..dfcb7162c80 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el | |||
| @@ -1631,7 +1631,7 @@ errors for shares like \"C$/\", which are common in Microsoft Windows." | |||
| 1631 | v 3 (format "Moving tmp file %s to %s" tmpfile filename) | 1631 | v 3 (format "Moving tmp file %s to %s" tmpfile filename) |
| 1632 | (unwind-protect | 1632 | (unwind-protect |
| 1633 | (unless (tramp-smb-send-command | 1633 | (unless (tramp-smb-send-command |
| 1634 | v (format "put %s \"%s\"" | 1634 | v (format "put \"%s\" \"%s\"" |
| 1635 | tmpfile (tramp-smb-get-localname v))) | 1635 | tmpfile (tramp-smb-get-localname v))) |
| 1636 | (tramp-error v 'file-error "Cannot write `%s'" filename)) | 1636 | (tramp-error v 'file-error "Cannot write `%s'" filename)) |
| 1637 | (delete-file tmpfile))) | 1637 | (delete-file tmpfile))) |
| @@ -1695,9 +1695,8 @@ If VEC has no cifs capabilities, exchange \"/\" by \"\\\\\"." | |||
| 1695 | (when (string-match "\\(\\$\\$\\)\\(/\\|$\\)" localname) | 1695 | (when (string-match "\\(\\$\\$\\)\\(/\\|$\\)" localname) |
| 1696 | (setq localname (replace-match "$" nil nil localname 1))) | 1696 | (setq localname (replace-match "$" nil nil localname 1))) |
| 1697 | 1697 | ||
| 1698 | ;; A period followed by a space, or trailing periods and spaces, | 1698 | ;; A trailing space is not supported. |
| 1699 | ;; are not supported. | 1699 | (when (string-match-p " $" localname) |
| 1700 | (when (string-match-p "\\. \\|\\.$\\| $" localname) | ||
| 1701 | (tramp-error | 1700 | (tramp-error |
| 1702 | vec 'file-error | 1701 | vec 'file-error |
| 1703 | "Invalid file name %s" (tramp-make-tramp-file-name vec localname))) | 1702 | "Invalid file name %s" (tramp-make-tramp-file-name vec localname))) |
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 61fa6a5ae4e..9071beedf2e 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -2028,17 +2028,7 @@ Also see `ignore'." | |||
| 2028 | :type 'user-error) | 2028 | :type 'user-error) |
| 2029 | (should-error | 2029 | (should-error |
| 2030 | (expand-file-name "/method:user1@host1|ssh:user2@host2:/path/to/file") | 2030 | (expand-file-name "/method:user1@host1|ssh:user2@host2:/path/to/file") |
| 2031 | :type 'user-error)) | 2031 | :type 'user-error))) |
| 2032 | |||
| 2033 | ;; Samba does not support file names with periods followed by | ||
| 2034 | ;; spaces, and trailing periods or spaces. | ||
| 2035 | (when (tramp--test-smb-p) | ||
| 2036 | (dolist (file '("foo." "foo. bar" "foo ")) | ||
| 2037 | (should-error | ||
| 2038 | (tramp-smb-get-localname | ||
| 2039 | (tramp-dissect-file-name | ||
| 2040 | (expand-file-name file tramp-test-temporary-file-directory))) | ||
| 2041 | :type 'file-error)))) | ||
| 2042 | 2032 | ||
| 2043 | (ert-deftest tramp-test04-substitute-in-file-name () | 2033 | (ert-deftest tramp-test04-substitute-in-file-name () |
| 2044 | "Check `substitute-in-file-name'." | 2034 | "Check `substitute-in-file-name'." |