Skip to content
This repository was archived by the owner on Jul 3, 2024. It is now read-only.

Commit 805c192

Browse files
committed
Fix version checks so they are same as before
1 parent 1d3a79e commit 805c192

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/angular_xss/haml.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
if Gem::Version.new(Haml::VERSION) < Gem::Version.new(5)
1+
haml_version = Gem::Version.new(Haml::VERSION)
2+
3+
if haml_version < Gem::Version.new(5)
24
# Use module_eval so we crash when Haml::Helpers has not yet been loaded.
35
Haml::Helpers.module_eval do
46
def html_escape_with_escaping_angular_expressions(s)
@@ -8,8 +10,10 @@ def html_escape_with_escaping_angular_expressions(s)
810
alias_method :html_escape_without_escaping_angular_expressions, :html_escape
911
alias_method :html_escape, :html_escape_with_escaping_angular_expressions
1012
end
11-
elsif Gem::Version.new(Haml::VERSION) < Gem::Version.new(6)
13+
elsif haml_version < Gem::Version.new('5.2')
1214
# Haml 5.0 and 5.1 fall back to erb
15+
elsif haml_version < Gem::Version.new(6)
16+
# HAML 5.2+
1317
Haml::Helpers.module_eval do
1418
def html_escape_without_haml_xss_with_escaping_angular_expressions(s)
1519
html_escape_without_haml_xss_without_escaping_angular_expressions(AngularXss::Escaper.escape_if_unsafe(s))
@@ -19,7 +23,8 @@ def html_escape_without_haml_xss_with_escaping_angular_expressions(s)
1923
alias_method :html_escape_without_haml_xss, :html_escape_without_haml_xss_with_escaping_angular_expressions
2024
end
2125
else
22-
# Haml 6+ ditched most of is helpers. in favor of Haml::Util.escape_html
26+
# Haml 6+
27+
# It ditched most of is own helpers in favor of Haml::Util.escape_html
2328
# https://github.com/haml/haml/blob/main/CHANGELOG.md#600
2429
# https://github.com/haml/haml/compare/v5.2.2...v6.3.0
2530
# https://github.com/haml/haml/blob/v6.3.0/lib/haml/util.rb

0 commit comments

Comments
 (0)