]> git.eshelyaron.com Git - emacs.git/commitdiff
Ignore directory symlinks in directory-files-recursively
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Fri, 12 Dec 2014 10:52:58 +0000 (11:52 +0100)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Fri, 12 Dec 2014 10:52:58 +0000 (11:52 +0100)
* files.el (directory-files-recursively): Don't follow symlinks to
other directories.

lisp/ChangeLog
lisp/files.el

index 75effaa865dd2397c64d1b3b622e5cdda252d359..0410b226e00a254bb25ebd88deb782bc27be7616 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-12  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * files.el (directory-files-recursively): Don't follow symlinks to
+       other directories.
+
 2014-12-12  Eric S. Raymond  <esr@snark.thyrsus.com>
 
        * vc/vc-dav.el, vc/vc-git.el, vc/vc-hg.el, vc/vc-src.el,
index 568c1bb58b1c0126fe86d5435aebfe33cc5f45b2..40972d48b942df8493cd8e5812861c3043d92ed3 100644 (file)
@@ -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))))