Skip to content

Commit e9b183c

Browse files
committed
Anemone::Page#links: restored upwards dir traversal
[FIXRM rapid7#7853]
1 parent 714fc83 commit e9b183c

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

lib/anemone/page.rb

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,21 @@ def links
103103
@links = run_extractors
104104

105105
@links |= @links.map do |u|
106-
# back-off to the parent dir
106+
# back-off to the parent dir
107107
to_absolute( URI( u.path.gsub( /(.*\/)[^\/]+$/, "\\1" ) ) ) rescue next
108108
end.uniq.compact
109109

110-
@links |= @links.map do |u|
111-
bits = u.path.split( '/' )
112-
while bits.length > 0
113-
bits.pop
114-
to_absolute( URI( bits.join( '/' ) ) ) rescue next
115-
end
116-
end.uniq.compact
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
117121

118122
@links.flatten!
119123
@links.uniq!

0 commit comments

Comments
 (0)