From f1bc4a76c5543a68700f75d32b619b200cab5ea9 Mon Sep 17 00:00:00 2001 From: Tasos Laskos Date: Tue, 2 Apr 2013 00:49:40 +0300 Subject: [PATCH] Anemone::Page#links: removed upwards dir traversal [Finishes #47241427] --- lib/anemone/page.rb | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/lib/anemone/page.rb b/lib/anemone/page.rb index 8e43a177e3..81d3f402e2 100644 --- a/lib/anemone/page.rb +++ b/lib/anemone/page.rb @@ -96,32 +96,7 @@ module Anemone # MODIFIED: Dig URLs from elements other than "A" refs # def links - return @links if @links - @links = [] - return @links if !doc - - @links = run_extractors - - @links |= @links.map do |u| - # back-off to the parent dir - to_absolute( URI( u.path.gsub( /(.*\/)[^\/]+$/, "\\1" ) ) ) rescue next - end.uniq.compact - - nlinks = [] - @links.each do |u| - bits = u.path.split('/') - while(bits.length > 0) - bits.pop - j = bits.join('/') - j = '/' if j.empty? - nlinks << to_absolute(URI(j)) rescue next - end - end - @links |= nlinks - - @links.flatten! - @links.uniq! - @links + @links ||= run_extractors end #