diff options
| author | Paul Eggert | 2020-08-27 14:46:52 -0700 |
|---|---|---|
| committer | Paul Eggert | 2020-08-27 14:49:38 -0700 |
| commit | 0bbc84630f12e848e19c39dce01f3d14559bf70b (patch) | |
| tree | 8c2e252c0ea6ef65667f4df46c468ef2f0b50bc6 /test/src | |
| parent | 1153b238aef5a48bbecd5a58cd6a14dae9ec1d2f (diff) | |
| download | emacs-0bbc84630f12e848e19c39dce01f3d14559bf70b.tar.gz emacs-0bbc84630f12e848e19c39dce01f3d14559bf70b.zip | |
Fix recently-introduced expand-file-name bug
The bug was that (expand-file-name "~") returned something
like "/home/eggert/" instead of "/home/eggert".
Problem reported by Mattias Engdegård (Bug#26911#27).
* src/fileio.c (Fexpand_file_name): When concatenating NEWDIR to
NM, instead of stripping trailing slashes from NEWDIR (which can
turn non-symlinks into symlinks), strip leading slashes from NM.
This also simplifies the code by removing no-longer-needed DOS_NT
special-casing. Also, remove an unnecessary ‘target[length] = 0;’
as that byte will be overwritten by the next memcpy anyway.
* test/src/fileio-tests.el (fileio-tests--HOME-trailing-slash):
New test.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/fileio-tests.el | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el index 1516590795e..8b76912f5e1 100644 --- a/test/src/fileio-tests.el +++ b/test/src/fileio-tests.el | |||
| @@ -108,6 +108,14 @@ Also check that an encoding error can appear in a symlink." | |||
| 108 | (should (equal (expand-file-name "~/bar") "x:/foo/bar"))) | 108 | (should (equal (expand-file-name "~/bar") "x:/foo/bar"))) |
| 109 | (setenv "HOME" old-home))) | 109 | (setenv "HOME" old-home))) |
| 110 | 110 | ||
| 111 | (ert-deftest fileio-tests--HOME-trailing-slash () | ||
| 112 | "Test that expand-file-name of \"~\" respects trailing slash." | ||
| 113 | (let ((old-home (getenv "HOME"))) | ||
| 114 | (dolist (home '("/a/b/c" "/a/b/c/")) | ||
| 115 | (setenv "HOME" home) | ||
| 116 | (should (equal (expand-file-name "~") (expand-file-name home)))) | ||
| 117 | (setenv "HOME" old-home))) | ||
| 118 | |||
| 111 | (ert-deftest fileio-tests--expand-file-name-trailing-slash () | 119 | (ert-deftest fileio-tests--expand-file-name-trailing-slash () |
| 112 | (dolist (fooslashalias '("foo/" "foo//" "foo/." "foo//." "foo///././." | 120 | (dolist (fooslashalias '("foo/" "foo//" "foo/." "foo//." "foo///././." |
| 113 | "foo/a/..")) | 121 | "foo/a/..")) |