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

Merge pull request #38073 from benubois/escape_javascript

Improve escape_javascript performance.
This commit is contained in:
Kasper Timm Hansen 2019-12-23 00:55:59 +01:00 committed by GitHub
commit d2ae2c3103
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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