From 5d8bb89f0fa7d5f2824a914ce2b7c3841112c7a1 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 27 Dec 2016 10:12:06 +0200 Subject: [PATCH] Fix expand-file-name on DOS_NT systems when /: escaping is used * src/fileio.c (Fexpand_file_name) [DOS_NT]: Don't expand "~" in file names escaped by "/:". Don't recursively expand default-directory escaped with "/:" which is not followed by a drive spec. (Bug#25183) --- src/fileio.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/fileio.c b/src/fileio.c index 3ba85b2b903..1a744e02e28 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -884,6 +884,11 @@ filesystem tree, not (expand-file-name ".." dirname). */) /* Detect MSDOS file names with drive specifiers. */ && ! (IS_DRIVE (o[0]) && IS_DEVICE_SEP (o[1]) && IS_DIRECTORY_SEP (o[2])) + /* Detect escaped file names without drive spec after "/:". + These should not be recursively expanded, to avoid + including the default directory twice in the expanded + result. */ + && ! (o[0] == '/' && o[1] == ':') #ifdef WINDOWSNT /* Detect Windows file names in UNC format. */ && ! (IS_DIRECTORY_SEP (o[0]) && IS_DIRECTORY_SEP (o[1])) @@ -1064,7 +1069,11 @@ filesystem tree, not (expand-file-name ".." dirname). */) newdir = newdirlim = 0; - if (nm[0] == '~') /* prefix ~ */ + if (nm[0] == '~' /* prefix ~ */ +#ifdef DOS_NT + && !is_escaped /* don't expand ~ in escaped file names */ +#endif + ) { if (IS_DIRECTORY_SEP (nm[1]) || nm[1] == 0) /* ~ by itself */ -- 2.39.2