From 3431e82d16af3d5130f0218efd5fafaa797ed28a Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Fri, 12 Dec 2014 11:52:58 +0100 Subject: [PATCH] Ignore directory symlinks in directory-files-recursively * files.el (directory-files-recursively): Don't follow symlinks to other directories. --- lisp/ChangeLog | 5 +++++ lisp/files.el | 12 ++++++------ 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 @@ +2014-12-12 Lars Magne Ingebrigtsen + + * files.el (directory-files-recursively): Don't follow symlinks to + other directories. + 2014-12-12 Eric S. Raymond * 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." 'string<)) (unless (member file '("./" "../")) (if (= (aref file (1- (length file))) ?/) - (progn - (setq result (nconc result (directory-files-recursively - (expand-file-name file dir) - match include-directories))) + (let ((path (expand-file-name file dir))) + ;; Don't follow symlinks to other directories. + (unless (file-symlink-p path) + (setq result (nconc result (directory-files-recursively + path match include-directories)))) (when (and include-directories (string-match match (substring file 0 (1- (length file))))) - (setq result (nconc result (list - (expand-file-name file dir)))))) + (setq result (nconc result (list path))))) (when (string-match match file) (push (expand-file-name file dir) files))))) (nconc result (nreverse files)))) -- 2.39.2