Skip to content

Commit

Permalink
test: Get basic test case for scrubber
Browse files Browse the repository at this point in the history
  • Loading branch information
josecolella authored and flavorjones committed Dec 31, 2024
1 parent 868a852 commit c949968
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/integration/test_scrubbers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class IntegrationTestScrubbers < Loofah::TestCase
ENTITY_HACK_ATTACK_TEXT_SCRUB = "Hack attack!&lt;script&gt;alert('evil')&lt;/script&gt;"
ENTITY_HACK_ATTACK_TEXT_SCRUB_UNESC = "Hack attack!<script>alert('evil')</script>"

BREAKPOINT_FRAGMENT = "<p>Some text here in a logical paragraph.<br><br>Some more text, apparently a second paragraph.<br><br>Et cetera...</p>"
BREAKPOINT_RESULT = "<p>Some text here in a logical paragraph.</p><p>Some more text, apparently a second paragraph.</p><p>Et cetera...</p>"

context "scrubbing shortcuts" do
context "#scrub_document" do
it "is a shortcut for parse-and-scrub" do
Expand Down Expand Up @@ -236,6 +239,16 @@ def html5?
assert_equal doc, result
end
end

context ":double_breakpoint" do
it "replaces double line breaks with paragraph tags" do
doc = klass.parse("<html><body>#{BREAKPOINT_FRAGMENT}</body></html>")
result = doc.scrub!(:double_breakpoint)

assert_equal BREAKPOINT_RESULT, doc.xpath("/html/body").inner_html
assert_equal doc, result
end
end
end

context "#text" do
Expand Down

0 comments on commit c949968

Please sign in to comment.