Don't allow people to proxy a path to itself, or to another proxy.
This commit is contained in:
parent
6dad42bc77
commit
12c551228f
|
@ -31,6 +31,8 @@ module Middleman
|
||||||
# @param [String] target
|
# @param [String] target
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def proxy_to(target)
|
def proxy_to(target)
|
||||||
|
target = ::Middleman::Util.normalize_path(target)
|
||||||
|
raise "You can't proxy #{path} to itself!" if target == path
|
||||||
@proxied_to = target
|
@proxied_to = target
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -55,9 +57,13 @@ module Middleman
|
||||||
proxy_resource = store.find_resource_by_path(proxied_to)
|
proxy_resource = store.find_resource_by_path(proxied_to)
|
||||||
|
|
||||||
unless proxy_resource
|
unless proxy_resource
|
||||||
raise "Path #{path} proxies to unknown file #{proxied_to}"
|
raise "Path #{path} proxies to unknown file #{proxied_to}:#{store.resources.map(&:path)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if proxy_resource.proxy?
|
||||||
|
raise "You can't proxy #{path} to #{proxied_to} which is itself a proxy."
|
||||||
|
end
|
||||||
|
|
||||||
proxy_resource.source_file
|
proxy_resource.source_file
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -105,4 +111,4 @@ module Middleman
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue