[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master be147d2: Handle empty strings in Tramp's expand-fil
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] master be147d2: Handle empty strings in Tramp's expand-file-name implementations |
Date: |
Wed, 6 Mar 2019 06:06:21 -0500 (EST) |
branch: master
commit be147d24198479bd569e71603c1d80f579311872
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>
Handle empty strings in Tramp's expand-file-name implementations
* lisp/net/tramp.el (tramp-handle-expand-file-name):
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-expand-file-name):
* lisp/net/tramp-sh.el (tramp-sh-handle-expand-file-name):
* lisp/net/tramp-smb.el (tramp-smb-handle-expand-file-name):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-expand-file-name):
Handle empty NAME.
* test/lisp/net/tramp-tests.el (tramp-test01-file-name-syntax)
(tramp-test01-file-name-syntax-simplified)
(tramp-test01-file-name-syntax-separate): Use neutral IPv4 address.
(tramp-test05-expand-file-name): Check also "." and "".
---
lisp/net/tramp-gvfs.el | 2 ++
lisp/net/tramp-sh.el | 2 ++
lisp/net/tramp-smb.el | 2 ++
lisp/net/tramp-sudoedit.el | 2 ++
lisp/net/tramp.el | 2 ++
test/lisp/net/tramp-tests.el | 26 +++++++++++++++++++-------
6 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 569fdb5..2d8f420 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -883,6 +883,8 @@ file names."
"Like `expand-file-name' for Tramp files."
;; If DIR is not given, use DEFAULT-DIRECTORY or "/".
(setq dir (or dir default-directory "/"))
+ ;; Handle empty NAME.
+ (when (zerop (length name)) (setq name "."))
;; Unless NAME is absolute, concat DIR and NAME.
(unless (file-name-absolute-p name)
(setq name (concat (file-name-as-directory dir) name)))
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 58c2fe5..ee16138 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -2716,6 +2716,8 @@ If the localname part of the given file name starts with
\"/../\" then
the result will be a local, non-Tramp, file name."
;; If DIR is not given, use `default-directory' or "/".
(setq dir (or dir default-directory "/"))
+ ;; Handle empty NAME.
+ (when (zerop (length name)) (setq name "."))
;; Unless NAME is absolute, concat DIR and NAME.
(unless (file-name-absolute-p name)
(setq name (concat (file-name-as-directory dir) name)))
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index 64a8fa2..e6e2485 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -692,6 +692,8 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are
completely ignored."
"Like `expand-file-name' for Tramp files."
;; If DIR is not given, use DEFAULT-DIRECTORY or "/".
(setq dir (or dir default-directory "/"))
+ ;; Handle empty NAME.
+ (when (zerop (length name)) (setq name "."))
;; Unless NAME is absolute, concat DIR and NAME.
(unless (file-name-absolute-p name)
(setq name (concat (file-name-as-directory dir) name)))
diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el
index 42deaf3..0d9e04d 100644
--- a/lisp/net/tramp-sudoedit.el
+++ b/lisp/net/tramp-sudoedit.el
@@ -353,6 +353,8 @@ If the localname part of the given file name starts with
\"/../\" then
the result will be a local, non-Tramp, file name."
;; If DIR is not given, use `default-directory' or "/".
(setq dir (or dir default-directory "/"))
+ ;; Handle empty NAME.
+ (when (zerop (length name)) (setq name "."))
;; Unless NAME is absolute, concat DIR and NAME.
(unless (file-name-absolute-p name)
(setq name (concat (file-name-as-directory dir) name)))
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index b35b36e..97ec5e1 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3069,6 +3069,8 @@ User is always nil."
"Like `expand-file-name' for Tramp files."
;; If DIR is not given, use DEFAULT-DIRECTORY or "/".
(setq dir (or dir default-directory "/"))
+ ;; Handle empty NAME.
+ (when (zerop (length name)) (setq name "."))
;; Unless NAME is absolute, concat DIR and NAME.
(unless (file-name-absolute-p name)
(setq name (concat (file-name-as-directory dir) name)))
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index f470385..69d5ba8 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -238,8 +238,8 @@ properly. BODY shall not contain a timeout."
(should (tramp-tramp-file-p "/method:address@hidden::1]:"))
;; Using an IPv4 mapped IPv6 address.
- (should (tramp-tramp-file-p "/method:[::ffff:192.168.0.1]:"))
- (should (tramp-tramp-file-p "/method:address@hidden::ffff:192.168.0.1]:"))
+ (should (tramp-tramp-file-p "/method:[::ffff:1.2.3.4]:"))
+ (should (tramp-tramp-file-p "/method:address@hidden::ffff:1.2.3.4]:"))
;; Local file name part.
(should (tramp-tramp-file-p "/method:::"))
@@ -268,7 +268,7 @@ properly. BODY shall not contain a timeout."
(should-not (tramp-tramp-file-p "/1.2.3.4:"))
(should-not (tramp-tramp-file-p "/[]:"))
(should-not (tramp-tramp-file-p "/[::1]:"))
- (should-not (tramp-tramp-file-p "/[::ffff:192.168.0.1]:"))
+ (should-not (tramp-tramp-file-p "/[::ffff:1.2.3.4]:"))
(should-not (tramp-tramp-file-p "/host:/:"))
(should-not (tramp-tramp-file-p "/host1|host2:"))
(should-not (tramp-tramp-file-p "/address@hidden|address@hidden:"))
@@ -318,8 +318,8 @@ properly. BODY shall not contain a timeout."
(should (tramp-tramp-file-p "/address@hidden::1]:"))
;; Using an IPv4 mapped IPv6 address.
- (should (tramp-tramp-file-p "/[::ffff:192.168.0.1]:"))
- (should (tramp-tramp-file-p "/address@hidden::ffff:192.168.0.1]:"))
+ (should (tramp-tramp-file-p "/[::ffff:1.2.3.4]:"))
+ (should (tramp-tramp-file-p "/address@hidden::ffff:1.2.3.4]:"))
;; Local file name part.
(should (tramp-tramp-file-p "/host::"))
@@ -372,8 +372,8 @@ properly. BODY shall not contain a timeout."
(should (tramp-tramp-file-p "/[method/user@::1]"))
;; Using an IPv4 mapped IPv6 address.
- (should (tramp-tramp-file-p "/[method/::ffff:192.168.0.1]"))
- (should (tramp-tramp-file-p "/[method/user@::ffff:192.168.0.1]"))
+ (should (tramp-tramp-file-p "/[method/::ffff:1.2.3.4]"))
+ (should (tramp-tramp-file-p "/[method/user@::ffff:1.2.3.4]"))
;; Local file name part.
(should (tramp-tramp-file-p "/[method/]"))
@@ -1988,6 +1988,18 @@ properly. BODY shall not contain a timeout."
(should
(string-equal
(expand-file-name "/method:host:/path/../file") "/method:host:/file"))
+ (should
+ (string-equal
+ (expand-file-name "/method:host:/path/.") "/method:host:/path"))
+ (should
+ (string-equal
+ (expand-file-name "/method:host:/path/..") "/method:host:/"))
+ (should
+ (string-equal
+ (expand-file-name "." "/method:host:/path/") "/method:host:/path"))
+ (should
+ (string-equal
+ (expand-file-name "" "/method:host:/path/") "/method:host:/path"))
;; Quoting local part.
(should
(string-equal
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master be147d2: Handle empty strings in Tramp's expand-file-name implementations,
Michael Albinus <=