diff options
author | Paul Gallagher <gallagher.paul@gmail.com> | 2011-06-08 22:46:15 +0800 |
---|---|---|
committer | Prem Sichanugrist <s@sikachu.com> | 2011-06-08 11:05:15 -0400 |
commit | bf2f039a93d1b5bacffcda14e2c58f39dfcf7fd4 (patch) | |
tree | de7ae76bcec782d718627aa03e8a0962fd244875 /actionpack/lib/action_view/helpers | |
parent | b64524d6fdacdd03277efd7b12ff0e8fa97737e2 (diff) | |
download | rails-bf2f039a93d1b5bacffcda14e2c58f39dfcf7fd4.tar.gz rails-bf2f039a93d1b5bacffcda14e2c58f39dfcf7fd4.tar.bz2 rails-bf2f039a93d1b5bacffcda14e2c58f39dfcf7fd4.zip |
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
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r-- | actionpack/lib/action_view/helpers/javascript_helper.rb | 2 |
1 files changed, 1 insertions, 1 deletions
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 |