1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Improve escape_javascript performance.

This commit is contained in:
Ben Ubois 2019-12-22 23:52:37 +01:00
parent 49d1b5a98d
commit 2bb7dbf75d

View file

@ -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