diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2020-08-26 13:25:35 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2020-08-26 13:27:56 -0700 |
commit | 14fb657ba82da346d36f05f88da26f1c5498b798 (patch) | |
tree | ca60dbe7a621ad7a5d00b1a28f489caf15e4896a /test | |
parent | ff864be694247e5f6c8732afcbaeb1c0a8a8a124 (diff) | |
download | emacs-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')
-rw-r--r-- | test/lisp/net/tramp-tests.el | 11 | ||||
-rw-r--r-- | test/src/fileio-tests.el | 11 |
2 files changed, 15 insertions, 7 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 7e9ae33f843..aa00c07f794 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -2131,16 +2131,16 @@ is greater than 10. (expand-file-name "/method:host:/path/../file") "/method:host:/file")) (should (string-equal - (expand-file-name "/method:host:/path/.") "/method:host:/path")) + (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")) + (expand-file-name "." "/method:host:/path/") "/method:host:/path/")) (should (string-equal - (expand-file-name "" "/method:host:/path/") "/method:host:/path")) + (expand-file-name "" "/method:host:/path/") "/method:host:/path/")) ;; Quoting local part. (should (string-equal @@ -2155,12 +2155,9 @@ is greater than 10. "/method:host:/:/~/path/file")))) ;; The following test is inspired by Bug#26911 and Bug#34834. They -;; are rather bugs in `expand-file-name', and it fails for all Emacs -;; versions. Test added for later, when they are fixed. +;; were bugs in `expand-file-name'. (ert-deftest tramp-test05-expand-file-name-relative () "Check `expand-file-name'." - ;; Mark as failed until bug has been fixed. - :expected-result :failed (skip-unless (tramp--test-enabled)) ;; These are the methods the test doesn't fail. 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) |