Skip to content

Commit f1bc4a7

Browse files
committed
Anemone::Page#links: removed upwards dir traversal
[Finishes #47241427]
1 parent 3a030b2 commit f1bc4a7

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

lib/anemone/page.rb

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -96,32 +96,7 @@ def run_extractors
9696
# MODIFIED: Dig URLs from elements other than "A" refs
9797
#
9898
def links
99-
return @links if @links
100-
@links = []
101-
return @links if !doc
102-
103-
@links = run_extractors
104-
105-
@links |= @links.map do |u|
106-
# back-off to the parent dir
107-
to_absolute( URI( u.path.gsub( /(.*\/)[^\/]+$/, "\\1" ) ) ) rescue next
108-
end.uniq.compact
109-
110-
nlinks = []
111-
@links.each do |u|
112-
bits = u.path.split('/')
113-
while(bits.length > 0)
114-
bits.pop
115-
j = bits.join('/')
116-
j = '/' if j.empty?
117-
nlinks << to_absolute(URI(j)) rescue next
118-
end
119-
end
120-
@links |= nlinks
121-
122-
@links.flatten!
123-
@links.uniq!
124-
@links
99+
@links ||= run_extractors
125100
end
126101

127102
#

0 commit comments

Comments
 (0)