Skip to content

Commit

Permalink
test: fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Aug 28, 2020
1 parent 7f3a047 commit 6429526
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions test/integration/test_ad_hoc.rb
Expand Up @@ -222,38 +222,40 @@ def test_dont_remove_whitespace_between_tags
#
context "comments outside html" do
context "bare comments" do
HTML = "<!-- --!><script>alert(1)</script><!-- -->"
let(:html) { "<!-- --!><script>alert(1)</script><!-- -->" }

it "Loofah.document removes the comment" do
sanitized = Loofah.document(HTML)
sanitized = Loofah.document(html)
sanitized_html = sanitized.to_html
refute_match(/--/, sanitized_html)
end

it "Loofah.scrub_document removes the comment" do
sanitized = Loofah.scrub_document(HTML, :prune)
sanitized = Loofah.scrub_document(html, :prune)
sanitized_html = sanitized.to_html
refute_match(/--/, sanitized_html)
end
end

context "doc with comments outside HTML" do
HTML = <<~EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<!-- spaces ->
<!-- tabs -->
<!-- more spaces -->
<html><body><div>hello
EOF
let(:html) do
<<~EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<!-- spaces ->
<!-- tabs -->
<!-- more spaces -->
<html><body><div>hello
EOF
end

it "Loofah.document removes the comment" do
sanitized = Loofah.document(HTML)
sanitized = Loofah.document(html)
sanitized_html = sanitized.to_html
refute_match(/--/, sanitized_html)
end

it "Loofah.scrub_document removes the comment" do
sanitized = Loofah.scrub_document(HTML, :prune)
sanitized = Loofah.scrub_document(html, :prune)
sanitized_html = sanitized.to_html
refute_match(/--/, sanitized_html)
end
Expand Down

0 comments on commit 6429526

Please sign in to comment.