summaryrefslogtreecommitdiff
path: root/doc
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 /doc
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 'doc')
-rw-r--r--doc/lispref/files.texi16
1 files changed, 14 insertions, 2 deletions
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index 92cbc2a1c91..090c54f8cd9 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -2438,14 +2438,26 @@ This is for the sake of filesystems that have the concept of a
superroot above the root directory @file{/}. On other filesystems,
@file{/../} is interpreted exactly the same as @file{/}.
+If a filename must be that of a directory, its expansion must be too.
+For example, if a filename ends in @samp{/} or @samp{/.} or @samp{/..}
+then its expansion ends in @samp{/} so that it cannot be
+misinterpreted as the name of a symbolic link:
+
+@example
+@group
+(expand-file-name "/a///b//.")
+ @result{} "/a/b/"
+@end group
+@end example
+
Expanding @file{.} or the empty string returns the default directory:
@example
@group
(expand-file-name "." "/usr/spool/")
- @result{} "/usr/spool"
+ @result{} "/usr/spool/"
(expand-file-name "" "/usr/spool/")
- @result{} "/usr/spool"
+ @result{} "/usr/spool/"
@end group
@end example