From 2668dce1c004d19f1c94cbde9151cef0aa7ec120 Mon Sep 17 00:00:00 2001 From: huskins Date: Wed, 13 Jul 2011 13:06:03 -0400 Subject: Added view template invalid name check, along with tests. No merges in commit. --- actionpack/lib/action_view/renderer/partial_renderer.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'actionpack/lib/action_view/renderer/partial_renderer.rb') diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionpack/lib/action_view/renderer/partial_renderer.rb index a351fbc04f..e31712eb73 100644 --- a/actionpack/lib/action_view/renderer/partial_renderer.rb +++ b/actionpack/lib/action_view/renderer/partial_renderer.rb @@ -301,6 +301,12 @@ module ActionView paths.map! { |path| retrieve_variable(path).unshift(path) } end + if String === partial && @variable !~ /^[a-z_][a-zA-Z_0-9]*$/ + raise ArgumentError.new("The partial name (#{partial}) is not a valid Ruby identifier; " + + "make sure your partial name starts with a letter or underscore, " + + "and is followed by any combinations of letters, numbers, or underscores.") + end + self end -- cgit v1.2.3