From 12c551228fade3e003de3c8793da63007a93f198 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sat, 7 Jul 2012 20:36:37 -0700 Subject: [PATCH] Don't allow people to proxy a path to itself, or to another proxy. --- .../lib/middleman-core/sitemap/extensions/proxies.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb b/middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb index ae7a2aee..2fe1b2bd 100644 --- a/middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb +++ b/middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb @@ -31,6 +31,8 @@ module Middleman # @param [String] target # @return [void] def proxy_to(target) + target = ::Middleman::Util.normalize_path(target) + raise "You can't proxy #{path} to itself!" if target == path @proxied_to = target end @@ -55,9 +57,13 @@ module Middleman proxy_resource = store.find_resource_by_path(proxied_to) 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 + if proxy_resource.proxy? + raise "You can't proxy #{path} to #{proxied_to} which is itself a proxy." + end + proxy_resource.source_file end end @@ -105,4 +111,4 @@ module Middleman end end end -end \ No newline at end of file +end