aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-05-29 20:13:58 +0000
committerRichard M. Stallman1993-05-29 20:13:58 +0000
commitcf65b429535065d72290e9ac443674161533d810 (patch)
tree02534f91bfe5688b9a2b435da42b5e77f0bcd594
parent3517b2e9e10ae252f8563b483cfebe0bcdfd5da6 (diff)
downloademacs-cf65b429535065d72290e9ac443674161533d810.tar.gz
emacs-cf65b429535065d72290e9ac443674161533d810.zip
(file-chase-links): Handle leading .. in symlink target.
-rw-r--r--lisp/files.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 44aea8525ed..f46f27b7602 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -351,6 +351,20 @@ unlike `file-truename'."
351 (while (setq tem (file-symlink-p newname)) 351 (while (setq tem (file-symlink-p newname))
352 (if (= count 0) 352 (if (= count 0)
353 (error "Apparent cycle of symbolic links for %s" filename)) 353 (error "Apparent cycle of symbolic links for %s" filename))
354 ;; Handle `..' by hand, since it needs to work in the
355 ;; target of any directory symlink.
356 ;; This code is not quite complete; it does not handle
357 ;; embedded .. in some cases such as ./../foo and foo/bar/../../../lose.
358 (while (string-match "\\.\\./" tem)
359 (setq tem (substring tem 3))
360 (setq newname (file-name-as-directory
361 ;; Do the .. by hand.
362 (directory-file-name
363 (file-name-directory
364 ;; Chase links in the default dir of the symlink.
365 (file-chase-links
366 (directory-file-name
367 (file-name-directory newname))))))))
354 (setq newname (expand-file-name tem (file-name-directory newname))) 368 (setq newname (expand-file-name tem (file-name-directory newname)))
355 (setq count (1- count))) 369 (setq count (1- count)))
356 newname)) 370 newname))