summaryrefslogtreecommitdiff
path: root/test/src/fileio-tests.el
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2020-08-26 13:25:35 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2020-08-26 13:27:56 -0700
commit14fb657ba82da346d36f05f88da26f1c5498b798 (patch)
treeca60dbe7a621ad7a5d00b1a28f489caf15e4896a /test/src/fileio-tests.el
parentff864be694247e5f6c8732afcbaeb1c0a8a8a124 (diff)
downloademacs-14fb657ba82da346d36f05f88da26f1c5498b798.tar.gz
Fix expand-file-name symlink-to-dir bug
Problem reported by Yegor Timoshenko (Bug#26911), and I ran into it myself recently in normal-top-level. * doc/lispref/files.texi (File Name Expansion), etc/NEWS: Mention this. * src/fileio.c (Fexpand_file_name): Expand "/a/b/." to "/a/b/" not "/a/b", to avoid misinterpreting a symlink "/a/b". Similarly, expand "/a/b/c/.." to "/a/b/" not "/a/b". * test/lisp/net/tramp-tests.el (tramp-test05-expand-file-name): Adjust to match new behavior. (tramp-test05-expand-file-name-relative): This test now succeeds, at least on Fedora 31. * test/src/fileio-tests.el: (fileio-tests--expand-file-name-trailing-slash) New test.
Diffstat (limited to 'test/src/fileio-tests.el')
-rw-r--r--test/src/fileio-tests.el11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el
index 96b03a01372..1516590795e 100644
--- a/test/src/fileio-tests.el
+++ b/test/src/fileio-tests.el
@@ -108,6 +108,17 @@ Also check that an encoding error can appear in a symlink."
(should (equal (expand-file-name "~/bar") "x:/foo/bar")))
(setenv "HOME" old-home)))
+(ert-deftest fileio-tests--expand-file-name-trailing-slash ()
+ (dolist (fooslashalias '("foo/" "foo//" "foo/." "foo//." "foo///././."
+ "foo/a/.."))
+ (should (equal (expand-file-name fooslashalias "/") "/foo/"))
+ (should (equal (expand-file-name (concat "/" fooslashalias)) "/foo/")))
+ (should (equal (expand-file-name "." "/usr/spool/") "/usr/spool/"))
+ (should (equal (expand-file-name "" "/usr/spool/") "/usr/spool/"))
+ ;; Trailing "B/C/.." means B must be a directory.
+ (should (equal (expand-file-name "/a/b/c/..") "/a/b/"))
+ (should (equal (expand-file-name "/a/b/c/../") "/a/b/")))
+
(ert-deftest fileio-tests--insert-file-interrupt ()
(let ((text "-*- coding: binary -*-\n\xc3\xc3help")
f)