Skip to content

Commit

Permalink
test: avoid renaming nodes to avoid errors in JRuby
Browse files Browse the repository at this point in the history
Xerces doesn't allow node renaming (but libxml2 does)
  • Loading branch information
flavorjones committed May 11, 2023
1 parent 4d79266 commit fe9aa6f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/sanitizer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -328,20 +328,20 @@ def scrubber.scrub(node); node.name = "h1"; end

def test_should_accept_loofah_inheriting_scrubber
scrubber = Loofah::Scrubber.new
def scrubber.scrub(node); node.name = "h1"; end
def scrubber.scrub(node); node.replace("<h1>#{node.inner_html}</h1>"); end

html = "<script>hello!</script>"
assert_equal "<h1>hello!</h1>", safe_list_sanitize(html, scrubber: scrubber)
end

def test_should_accept_loofah_scrubber_that_wraps_a_block
scrubber = Loofah::Scrubber.new { |node| node.name = "h1" }
scrubber = Loofah::Scrubber.new { |node| node.replace("<h1>#{node.inner_html}</h1>") }
html = "<script>hello!</script>"
assert_equal "<h1>hello!</h1>", safe_list_sanitize(html, scrubber: scrubber)
end

def test_custom_scrubber_takes_precedence_over_other_options
scrubber = Loofah::Scrubber.new { |node| node.name = "h1" }
scrubber = Loofah::Scrubber.new { |node| node.replace("<h1>#{node.inner_html}</h1>") }
html = "<script>hello!</script>"
assert_equal "<h1>hello!</h1>", safe_list_sanitize(html, scrubber: scrubber, tags: ["foo"])
end
Expand Down

0 comments on commit fe9aa6f

Please sign in to comment.