aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen2014-12-12 11:52:58 +0100
committerLars Magne Ingebrigtsen2014-12-12 11:52:58 +0100
commit3431e82d16af3d5130f0218efd5fafaa797ed28a (patch)
tree32ab731858bc1d6dfe714fce18f7eae292cc4415
parent14efb831885fcdefb199e2ca8d28e73e01f55916 (diff)
downloademacs-3431e82d16af3d5130f0218efd5fafaa797ed28a.tar.gz
emacs-3431e82d16af3d5130f0218efd5fafaa797ed28a.zip
Ignore directory symlinks in directory-files-recursively
* files.el (directory-files-recursively): Don't follow symlinks to other directories.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/files.el12
2 files changed, 11 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 75effaa865d..0410b226e00 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12014-12-12 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * files.el (directory-files-recursively): Don't follow symlinks to
4 other directories.
5
12014-12-12 Eric S. Raymond <esr@snark.thyrsus.com> 62014-12-12 Eric S. Raymond <esr@snark.thyrsus.com>
2 7
3 * vc/vc-dav.el, vc/vc-git.el, vc/vc-hg.el, vc/vc-src.el, 8 * vc/vc-dav.el, vc/vc-git.el, vc/vc-hg.el, vc/vc-src.el,
diff --git a/lisp/files.el b/lisp/files.el
index 568c1bb58b1..40972d48b94 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -772,15 +772,15 @@ If INCLUDE-DIRECTORIES, also include directories that have matching names."
772 'string<)) 772 'string<))
773 (unless (member file '("./" "../")) 773 (unless (member file '("./" "../"))
774 (if (= (aref file (1- (length file))) ?/) 774 (if (= (aref file (1- (length file))) ?/)
775 (progn 775 (let ((path (expand-file-name file dir)))
776 (setq result (nconc result (directory-files-recursively 776 ;; Don't follow symlinks to other directories.
777 (expand-file-name file dir) 777 (unless (file-symlink-p path)
778 match include-directories))) 778 (setq result (nconc result (directory-files-recursively
779 path match include-directories))))
779 (when (and include-directories 780 (when (and include-directories
780 (string-match match 781 (string-match match
781 (substring file 0 (1- (length file))))) 782 (substring file 0 (1- (length file)))))
782 (setq result (nconc result (list 783 (setq result (nconc result (list path)))))
783 (expand-file-name file dir))))))
784 (when (string-match match file) 784 (when (string-match match file)
785 (push (expand-file-name file dir) files))))) 785 (push (expand-file-name file dir) files)))))
786 (nconc result (nreverse files)))) 786 (nconc result (nreverse files))))