Permalink
Browse files

Ignore internal or looped symlinks.

See also:

  https://wincent.com/issues/1838

Signed-off-by: Wincent Colaiuta <win@wincent.com>
  • Loading branch information...
1 parent e926704 commit 3cabca33a1b4a8d6ec7cf9c407b3651412fa626d @pazustep pazustep committed with Dec 16, 2011
Showing with 8 additions and 0 deletions.
  1. +8 −0 ruby/command-t/scanner/file_scanner.rb
@@ -76,6 +76,13 @@ def path_excluded? path
::VIM::evaluate("empty(expand(fnameescape('#{path}')))").to_i == 1
end
+ def looped_symlink? path
+ if File.symlink?(path)
+ target = File.expand_path(File.readlink(path), File.dirname(path))
+ target.include?(@path) || @path.include?(target)
+ end
+ end
+
def add_paths_for_directory dir, accumulator
Dir.foreach(dir) do |entry|
next if ['.', '..'].include?(entry)
@@ -88,6 +95,7 @@ def add_paths_for_directory dir, accumulator
elsif File.directory?(path)
next if @depth >= @max_depth
next if (entry.match(/\A\./) && !@scan_dot_directories)
+ next if looped_symlink?(path)
@depth += 1
add_paths_for_directory path, accumulator
@depth -= 1

0 comments on commit 3cabca3

Please sign in to comment.