This repository was archived by the owner on Jul 3, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Original file line number Diff line number Diff line change 1
1
if ERB ::Util . private_method_defined? :unwrapped_html_escape
2
- # Rails 4.2 +
2
+ # Rails 4.2+
3
3
# https://github.com/rails/rails/blob/main/activesupport/lib/active_support/core_ext/erb/util.rb
4
4
module ERBUtilExt
5
5
def html_escape_once ( s )
@@ -9,7 +9,7 @@ def html_escape_once(s)
9
9
def unwrapped_html_escape ( s )
10
10
super ( AngularXss ::Escaper . escape_if_unsafe ( s ) )
11
11
end
12
- # Note that html_escape() and h() are passively fixed as they are calling the new methods.
12
+ # Note that html_escape() and h() are passively fixed as they are calling the two methods above
13
13
end
14
14
ERB ::Util . prepend ERBUtilExt
15
15
ERB ::Util . singleton_class . prepend ERBUtilExt
Original file line number Diff line number Diff line change @@ -14,26 +14,25 @@ def html_escape_with_escaping_angular_expressions(s)
14
14
# Haml 5.0 and 5.1 fall back to erb
15
15
elsif haml_version < Gem ::Version . new ( 6 )
16
16
# HAML 5.2+
17
- Haml :: Helpers . module_eval do
18
- def html_escape_without_haml_xss_with_escaping_angular_expressions ( s )
19
- html_escape_without_haml_xss_without_escaping_angular_expressions ( AngularXss ::Escaper . escape_if_unsafe ( s ) )
17
+ module HTMLEscapeWithoutHAMLWithAngularXSS
18
+ def html_escape_without_haml_xss ( html )
19
+ super ( AngularXss ::Escaper . escape_if_unsafe ( html ) )
20
20
end
21
-
22
- alias_method :html_escape_without_haml_xss_without_escaping_angular_expressions , :html_escape_without_haml_xss
23
- alias_method :html_escape_without_haml_xss , :html_escape_without_haml_xss_with_escaping_angular_expressions
24
21
end
22
+
23
+ Haml ::Helpers . singleton_class . prepend HTMLEscapeWithoutHAMLWithAngularXSS
25
24
else
26
25
# Haml 6+
27
26
# It ditched most of is own helpers in favor of Haml::Util.escape_html
28
27
# https://github.com/haml/haml/blob/main/CHANGELOG.md#600
29
28
# https://github.com/haml/haml/compare/v5.2.2...v6.3.0
30
29
# https://github.com/haml/haml/blob/v6.3.0/lib/haml/util.rb
31
30
32
- module HamlUtilExt
31
+ module EscapeHTMLWithAngularXSS
33
32
def escape_html ( html )
34
33
super ( AngularXss ::Escaper . escape_if_unsafe ( html ) )
35
34
end
36
35
end
37
36
38
- Haml ::Util . singleton_class . prepend HamlUtilExt
37
+ Haml ::Util . singleton_class . prepend EscapeHTMLWithAngularXSS
39
38
end
You can’t perform that action at this time.
0 commit comments