From bf2f039a93d1b5bacffcda14e2c58f39dfcf7fd4 Mon Sep 17 00:00:00 2001 From: Paul Gallagher Date: Wed, 8 Jun 2011 22:46:15 +0800 Subject: Make escape_javascript happy to handle SafeBuffers * see GH#1553 * allow for the fact that gsub on SafeBuffer does not pass match variables $1, $2 etc to a block --- actionpack/lib/action_view/helpers/javascript_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_view') diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb index d7228bab67..8a6f2e84be 100644 --- a/actionpack/lib/action_view/helpers/javascript_helper.rb +++ b/actionpack/lib/action_view/helpers/javascript_helper.rb @@ -18,7 +18,7 @@ module ActionView # $('some_element').replaceWith('<%=j render 'some/element_template' %>'); def escape_javascript(javascript) if javascript - javascript.gsub(/(\\|<\/|\r\n|[\n\r"'])/) { JS_ESCAPE_MAP[$1] } + javascript.gsub(/(\\|<\/|\r\n|[\n\r"'])/) {|match| JS_ESCAPE_MAP[match] } else '' end -- cgit v1.2.3