From 2bb7dbf75d2c267c6a3149c178e111869c61cbfe Mon Sep 17 00:00:00 2001 From: Ben Ubois Date: Sun, 22 Dec 2019 23:52:37 +0100 Subject: [PATCH] Improve escape_javascript performance. --- actionview/lib/action_view/helpers/javascript_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actionview/lib/action_view/helpers/javascript_helper.rb b/actionview/lib/action_view/helpers/javascript_helper.rb index b680cb1bd3..c077403155 100644 --- a/actionview/lib/action_view/helpers/javascript_helper.rb +++ b/actionview/lib/action_view/helpers/javascript_helper.rb @@ -29,7 +29,7 @@ module ActionView if javascript.empty? result = "" else - result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"'])/u) { |match| JS_ESCAPE_MAP[match] } + result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"'])/u, JS_ESCAPE_MAP) end javascript.html_safe? ? result.html_safe : result end