1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
6 # * https://github.com/advisories/GHSA-65cv-r6x7-79hv
7 # * https://nvd.nist.gov/vuln/detail/CVE-2020-5267
9 # Until we upgrade to rails 5.2, this monkeypatch should be enough
10 ActionView::Helpers::JavaScriptHelper::JS_ESCAPE_MAP.merge!(
17 module ActionView::Helpers::JavaScriptHelper
18 alias :old_ej :escape_javascript
21 def escape_javascript(javascript)
22 javascript = javascript.to_s
26 result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"']|[`]|[$])/u, JS_ESCAPE_MAP)
28 javascript.html_safe? ? result.html_safe : result
31 alias :j :escape_javascript