@@ -54,7 +54,7 @@ def test_remove_xpaths_called_with_enumerable_xpaths
54
54
55
55
def test_strip_tags_with_quote
56
56
input = '<" <img src="trollface.gif" onload="alert(1)"> hi'
57
- expected = libxml_2_9_14_recovery ? ? %{<" hi} : %{ hi}
57
+ expected = libxml_2_9_14_recovery_lt ? ? %{<" hi} : %{ hi}
58
58
assert_equal ( expected , full_sanitize ( input ) )
59
59
end
60
60
@@ -77,19 +77,19 @@ def test_strip_tags_multiline
77
77
78
78
def test_remove_unclosed_tags
79
79
input = "This is <-- not\n a comment here."
80
- expected = libxml_2_9_14_recovery ? ? %{This is <-- not\n a comment here.} : %{This is }
80
+ expected = libxml_2_9_14_recovery_lt ? ? %{This is <-- not\n a comment here.} : %{This is }
81
81
assert_equal ( expected , full_sanitize ( input ) )
82
82
end
83
83
84
84
def test_strip_cdata
85
85
input = "This has a <![CDATA[<section>]]> here."
86
- expected = libxml_2_9_14_recovery ? ? %{This has a <![CDATA[]]> here.} : %{This has a ]]> here.}
86
+ expected = libxml_2_9_14_recovery_lt_bang ? ? %{This has a <![CDATA[]]> here.} : %{This has a ]]> here.}
87
87
assert_equal ( expected , full_sanitize ( input ) )
88
88
end
89
89
90
90
def test_strip_unclosed_cdata
91
91
input = "This has an unclosed <![CDATA[<section>]] here..."
92
- expected = libxml_2_9_14_recovery ? ? %{This has an unclosed <![CDATA[]] here...} : %{This has an unclosed ]] here...}
92
+ expected = libxml_2_9_14_recovery_lt_bang ? ? %{This has an unclosed <![CDATA[]] here...} : %{This has an unclosed ]] here...}
93
93
assert_equal ( expected , full_sanitize ( input ) )
94
94
end
95
95
@@ -458,13 +458,13 @@ def test_should_sanitize_img_vbscript
458
458
459
459
def test_should_sanitize_cdata_section
460
460
input = "<![CDATA[<span>section</span>]]>"
461
- expected = libxml_2_9_14_recovery ? ? %{<![CDATA[<span>section</span>]]>} : %{section]]>}
461
+ expected = libxml_2_9_14_recovery_lt_bang ? ? %{<![CDATA[<span>section</span>]]>} : %{section]]>}
462
462
assert_sanitized ( input , expected )
463
463
end
464
464
465
465
def test_should_sanitize_unterminated_cdata_section
466
466
input = "<![CDATA[<span>neverending..."
467
- expected = libxml_2_9_14_recovery ? ? %{<![CDATA[<span>neverending...</span>} : %{neverending...}
467
+ expected = libxml_2_9_14_recovery_lt_bang ? ? %{<![CDATA[<span>neverending...</span>} : %{neverending...}
468
468
assert_sanitized ( input , expected )
469
469
end
470
470
@@ -657,10 +657,17 @@ def convert_to_css_hex(string, escape_parens=false)
657
657
end . join
658
658
end
659
659
660
- def libxml_2_9_14_recovery?
660
+ def libxml_2_9_14_recovery_lt?
661
+ # changed in 2.9.14, see https://github.com/sparklemotion/nokogiri/releases/tag/v1.13.5
661
662
Nokogiri . method ( :uses_libxml? ) . arity == -1 && Nokogiri . uses_libxml? ( ">= 2.9.14" )
662
663
end
663
664
665
+ def libxml_2_9_14_recovery_lt_bang?
666
+ # changed in 2.9.14, see https://github.com/sparklemotion/nokogiri/releases/tag/v1.13.5
667
+ # then reverted in 2.10.0, see https://gitlab.gnome.org/GNOME/libxml2/-/issues/380
668
+ Nokogiri . method ( :uses_libxml? ) . arity == -1 && Nokogiri . uses_libxml? ( "= 2.9.14" )
669
+ end
670
+
664
671
def html5_mode?
665
672
::Loofah . respond_to? ( :html5_mode? ) && ::Loofah . html5_mode?
666
673
end
0 commit comments