@@ -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
@@ -464,13 +464,13 @@ def test_should_sanitize_img_vbscript
464
464
465
465
def test_should_sanitize_cdata_section
466
466
input = "<![CDATA[<span>section</span>]]>"
467
- expected = libxml_2_9_14_recovery ? ? %{<![CDATA[<span>section</span>]]>} : %{section]]>}
467
+ expected = libxml_2_9_14_recovery_lt_bang ? ? %{<![CDATA[<span>section</span>]]>} : %{section]]>}
468
468
assert_sanitized ( input , expected )
469
469
end
470
470
471
471
def test_should_sanitize_unterminated_cdata_section
472
472
input = "<![CDATA[<span>neverending..."
473
- expected = libxml_2_9_14_recovery ? ? %{<![CDATA[<span>neverending...</span>} : %{neverending...}
473
+ expected = libxml_2_9_14_recovery_lt_bang ? ? %{<![CDATA[<span>neverending...</span>} : %{neverending...}
474
474
assert_sanitized ( input , expected )
475
475
end
476
476
@@ -663,10 +663,17 @@ def convert_to_css_hex(string, escape_parens=false)
663
663
end . join
664
664
end
665
665
666
- def libxml_2_9_14_recovery?
666
+ def libxml_2_9_14_recovery_lt?
667
+ # changed in 2.9.14, see https://github.com/sparklemotion/nokogiri/releases/tag/v1.13.5
667
668
Nokogiri . method ( :uses_libxml? ) . arity == -1 && Nokogiri . uses_libxml? ( ">= 2.9.14" )
668
669
end
669
670
671
+ def libxml_2_9_14_recovery_lt_bang?
672
+ # changed in 2.9.14, see https://github.com/sparklemotion/nokogiri/releases/tag/v1.13.5
673
+ # then reverted in 2.10.0, see https://gitlab.gnome.org/GNOME/libxml2/-/issues/380
674
+ Nokogiri . method ( :uses_libxml? ) . arity == -1 && Nokogiri . uses_libxml? ( "= 2.9.14" )
675
+ end
676
+
670
677
def html5_mode?
671
678
::Loofah . respond_to? ( :html5_mode? ) && ::Loofah . html5_mode?
672
679
end
0 commit comments