Anemone::Page#links: restored upwards dir traversal

[FIXRM #7853]
unstable
Tasos Laskos 2013-03-29 23:07:46 +02:00
parent 714fc83cfe
commit e9b183cda2
1 changed files with 12 additions and 8 deletions

View File

@ -103,17 +103,21 @@ module Anemone
@links = run_extractors
@links |= @links.map do |u|
# back-off to the parent dir
# back-off to the parent dir
to_absolute( URI( u.path.gsub( /(.*\/)[^\/]+$/, "\\1" ) ) ) rescue next
end.uniq.compact
@links |= @links.map do |u|
bits = u.path.split( '/' )
while bits.length > 0
bits.pop
to_absolute( URI( bits.join( '/' ) ) ) rescue next
end
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!