diff options
| author | Paul Eggert | 2017-08-26 18:36:38 -0700 |
|---|---|---|
| committer | Paul Eggert | 2017-08-26 18:36:38 -0700 |
| commit | e8001d4c27e1e33c83b9994aac4d5fc3feada2da (patch) | |
| tree | 6910256d7cf7723aa1b3f7ab7779b91627ba52f6 /test/src | |
| parent | 937d9d7f60460edb1d3f978151599fddcbba2214 (diff) | |
| download | emacs-e8001d4c27e1e33c83b9994aac4d5fc3feada2da.tar.gz emacs-e8001d4c27e1e33c83b9994aac4d5fc3feada2da.zip | |
Do not munge contents of local symbolic links
This lets Emacs deal with arbitrary local symlinks without
mishandling their contents (Bug#28156). For example,
(progn (shell-command "ln -fs '~' 'x'") (rename-file "x" "/tmp/x"))
now consistently creates a symbolic link from '/tmp/x' to '~'.
Formerly, it did that only if the working directory was on the
same filesystem as /tmp; otherwise, it expanded the '~' to
the user's home directory.
* lisp/dired.el (dired-get-filename): Use files--name-absolute-system-p
instead of rolling our own code.
* lisp/files.el (files--name-absolute-system-p): New function.
(file-truename, file-chase-links): Use it to avoid mishandling
symlink contents that begin with ~.
(copy-directory, move-file-to-trash):
Use concat rather than expand-file-name, to avoid mishandling
symlink contents that begin with ~.
* src/fileio.c (Fmake_symbolic_link): Do not expand leading "~" in the
target unless interactive. Strip leading "/:" if interactive.
(emacs_readlinkat): Do not prepend "/:" to the link target if
it starts with "/" and contains ":" before NUL.
* test/src/fileio-tests.el (try-link): Rename from try-char,
and accept a string instead of a char. All uses changed.
(fileio-tests--symlink-failure): Also test leading ~, and "/:",
to test the new behavior.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/fileio-tests.el | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el index 2ef1b553ab4..5103d2f21e6 100644 --- a/test/src/fileio-tests.el +++ b/test/src/fileio-tests.el | |||
| @@ -19,14 +19,13 @@ | |||
| 19 | 19 | ||
| 20 | (require 'ert) | 20 | (require 'ert) |
| 21 | 21 | ||
| 22 | (defun try-char (char link) | 22 | (defun try-link (target link) |
| 23 | (let ((target (string char))) | 23 | (make-symbolic-link target link) |
| 24 | (make-symbolic-link target link) | 24 | (let* ((read-link (file-symlink-p link)) |
| 25 | (let* ((read-link (file-symlink-p link)) | 25 | (failure (unless (string-equal target read-link) |
| 26 | (failure (unless (string-equal target read-link) | 26 | (list 'string-equal target read-link)))) |
| 27 | (list 'string-equal target read-link)))) | 27 | (delete-file link) |
| 28 | (delete-file link) | 28 | failure)) |
| 29 | failure))) | ||
| 30 | 29 | ||
| 31 | (defun fileio-tests--symlink-failure () | 30 | (defun fileio-tests--symlink-failure () |
| 32 | (let* ((dir (make-temp-file "fileio" t)) | 31 | (let* ((dir (make-temp-file "fileio" t)) |
| @@ -36,9 +35,9 @@ | |||
| 36 | (char 0)) | 35 | (char 0)) |
| 37 | (while (and (not failure) (< char 127)) | 36 | (while (and (not failure) (< char 127)) |
| 38 | (setq char (1+ char)) | 37 | (setq char (1+ char)) |
| 39 | (unless (= char ?~) | 38 | (setq failure (try-link (string char) link))) |
| 40 | (setq failure (try-char char link)))) | 39 | (or failure |
| 41 | failure) | 40 | (try-link "/:" link))) |
| 42 | (delete-directory dir t)))) | 41 | (delete-directory dir t)))) |
| 43 | 42 | ||
| 44 | (ert-deftest fileio-tests--odd-symlink-chars () | 43 | (ert-deftest fileio-tests--odd-symlink-chars () |