File tree 2 files changed +15
-5
lines changed
2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -79,13 +79,20 @@ def test_whitewash_on_fragment
79
79
80
80
def test_fragment_whitewash_on_microsofty_markup
81
81
whitewashed = Loofah . fragment ( MSWORD_HTML ) . scrub! ( :whitewash )
82
- assert_equal "<p>Foo <b>BOLD</b></p>" , whitewashed . to_s . strip
82
+ if Nokogiri . uses_libxml? ( "<2.9.11" )
83
+ assert_equal "<p>Foo <b>BOLD</b></p>" , whitewashed . to_s . strip
84
+ else
85
+ assert_equal "<p>Foo <b>BOLD<p></p></b></p>" , whitewashed . to_s . strip
86
+ end
83
87
end
84
88
85
89
def test_document_whitewash_on_microsofty_markup
86
90
whitewashed = Loofah . document ( MSWORD_HTML ) . scrub! ( :whitewash )
87
- assert_match %r(<p>Foo <b>BOLD</b></p>) , whitewashed . to_s
88
- assert_equal "<p>Foo <b>BOLD</b></p>" , whitewashed . xpath ( "/html/body/*" ) . to_s
91
+ if Nokogiri . uses_libxml? ( "<2.9.11" )
92
+ assert_equal "<p>Foo <b>BOLD</b></p>" , whitewashed . xpath ( "/html/body/*" ) . to_s
93
+ else
94
+ assert_equal "<p>Foo <b>BOLD<p></p></b></p>" , whitewashed . xpath ( "/html/body/*" ) . to_s
95
+ end
89
96
end
90
97
91
98
def test_return_empty_string_when_nothing_left
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ class IntegrationTestScrubbers < Loofah::TestCase
8
8
9
9
WHITEWASH_FRAGMENT = "<o:div>no</o:div><div id='no'>foo</div><invalid>bar</invalid><!--[if gts mso9]><div>microsofty stuff</div><![endif]-->"
10
10
WHITEWASH_RESULT = "<div>foo</div>"
11
+ WHITEWASH_RESULT_LIBXML2911 = "<div>no</div>\n <div>foo</div>"
11
12
12
13
NOFOLLOW_FRAGMENT = '<a href="http://www.example.com/">Click here</a>'
13
14
NOFOLLOW_RESULT = '<a href="http://www.example.com/" rel="nofollow">Click here</a>'
@@ -68,7 +69,8 @@ class IntegrationTestScrubbers < Loofah::TestCase
68
69
doc = Loofah ::HTML ::Document . parse "<html><body>#{ WHITEWASH_FRAGMENT } </body></html>"
69
70
result = doc . scrub! :whitewash
70
71
71
- assert_equal WHITEWASH_RESULT , doc . xpath ( "/html/body" ) . inner_html
72
+ ww_result = Nokogiri . uses_libxml? ( "<2.9.11" ) ? WHITEWASH_RESULT : WHITEWASH_RESULT_LIBXML2911
73
+ assert_equal ww_result , doc . xpath ( "/html/body" ) . inner_html
72
74
assert_equal doc , result
73
75
end
74
76
end
@@ -246,7 +248,8 @@ class IntegrationTestScrubbers < Loofah::TestCase
246
248
doc = Loofah ::HTML ::DocumentFragment . parse "<div>#{ WHITEWASH_FRAGMENT } </div>"
247
249
result = doc . scrub! :whitewash
248
250
249
- assert_equal WHITEWASH_RESULT , doc . xpath ( "./div" ) . inner_html
251
+ ww_result = Nokogiri . uses_libxml? ( "<2.9.11" ) ? WHITEWASH_RESULT : WHITEWASH_RESULT_LIBXML2911
252
+ assert_equal ww_result , doc . xpath ( "./div" ) . inner_html
250
253
assert_equal doc , result
251
254
end
252
255
end
You can’t perform that action at this time.
0 commit comments