Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 3cabca33a1b4a8d6ec7cf9c407b3651412fa626d 1 parent e926704
@pazustep pazustep authored committed
Showing with 8 additions and 0 deletions.
  1. +8 −0 ruby/command-t/scanner/file_scanner.rb
View
8 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
Please sign in to comment.
Something went wrong with that request. Please try again.