diff options
author | Prem Sichanugrist <s@sikachu.com> | 2011-06-09 14:00:10 -0400 |
---|---|---|
committer | Prem Sichanugrist <s@sikachu.com> | 2011-06-09 14:30:02 -0400 |
commit | 8c8652c37f6f6969ce48d579a8c9a8ff668f995a (patch) | |
tree | 89783214af4fbf92f5ce9606c31804af65692faf /actionpack/lib | |
parent | 834bebf9cc5acbf2c6662d1e5458a2726d305341 (diff) | |
download | rails-8c8652c37f6f6969ce48d579a8c9a8ff668f995a.tar.gz rails-8c8652c37f6f6969ce48d579a8c9a8ff668f995a.tar.bz2 rails-8c8652c37f6f6969ce48d579a8c9a8ff668f995a.zip |
Make sure `escape_javascript` return `SafeBuffer` if the incoming argument is already html_safe
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/javascript_helper.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb index 8a6f2e84be..4484390fde 100644 --- a/actionpack/lib/action_view/helpers/javascript_helper.rb +++ b/actionpack/lib/action_view/helpers/javascript_helper.rb @@ -18,7 +18,8 @@ module ActionView # $('some_element').replaceWith('<%=j render 'some/element_template' %>'); def escape_javascript(javascript) if javascript - javascript.gsub(/(\\|<\/|\r\n|[\n\r"'])/) {|match| JS_ESCAPE_MAP[match] } + result = javascript.gsub(/(\\|<\/|\r\n|[\n\r"'])/) {|match| JS_ESCAPE_MAP[match] } + javascript.html_safe? ? result.html_safe : result else '' end |