Module: ActionView::Helpers::JavaScriptHelper

Defined in:
lib/legacy-rails-CVE-2020-5267-patch.rb

Instance Method Summary collapse

Instance Method Details

#escape_javascript(javascript) ⇒ Object Also known as: j



15
16
17
18
19
20
21
22
23
# File 'lib/legacy-rails-CVE-2020-5267-patch.rb', line 15

def escape_javascript(javascript)
  javascript = javascript.to_s
  if javascript.empty?
    result = ""
  else
    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

#old_ejObject



12
# File 'lib/legacy-rails-CVE-2020-5267-patch.rb', line 12

alias :old_ej :escape_javascript