Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add coverage for entities #227

Merged
merged 1 commit into from Feb 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 44 additions & 0 deletions test/integration/test_ad_hoc.rb
Expand Up @@ -315,5 +315,49 @@ def test_dont_remove_whitespace_between_tags

assert_equal(expected, actual.to_html)
end

describe "entities" do
it "handles & character" do
input = %{<div> this & that </div>}
expected = %{<div> this &amp; that </div>}
actual = Loofah.scrub_fragment(input, :escape)
assert_equal(expected, actual.to_html)
end

it "handles > character" do
input = %{<div> this > that </div>}
expected = %{<div> this &gt; that </div>}
actual = Loofah.scrub_fragment(input, :escape)
assert_equal(expected, actual.to_html)
end

it "handles < character" do
input = %{<div> this < that </div>}
expected = %{<div> this &lt; that </div>}
actual = Loofah.scrub_fragment(input, :escape)
assert_equal(expected, actual.to_html)
end

it "handles < character in an attribute" do
input = %{<div alt="this < that">wave</div>}
expected = %{<div alt="this &lt; that">wave</div>}
actual = Loofah.scrub_fragment(input, :escape)
assert_equal(expected, actual.to_html)
end

it "handles multiple < characters" do
input = %{<div> this <<</div>}
expected = %{<div> this &lt;&lt;</div>}
actual = Loofah.scrub_fragment(input, :escape)
assert_equal(expected, actual.to_html)
end

it "handles &lt; entity" do
input = %{<div> this &lt; that </div>}
expected = input
actual = Loofah.scrub_fragment(input, :escape)
assert_equal(expected, actual.to_html)
end
end
end
end