From f8c6249a829f29e6e563242cca8cd0dfb3c47de4 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Mon, 21 Feb 2022 18:50:16 -0500 Subject: [PATCH] test: add coverage for entities see https://github.com/sparklemotion/nokogiri/issues/2461 for background --- test/integration/test_ad_hoc.rb | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/test/integration/test_ad_hoc.rb b/test/integration/test_ad_hoc.rb index 356e8d1..eb96ff2 100644 --- a/test/integration/test_ad_hoc.rb +++ b/test/integration/test_ad_hoc.rb @@ -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 = %{
this & that
} + expected = %{
this & that
} + actual = Loofah.scrub_fragment(input, :escape) + assert_equal(expected, actual.to_html) + end + + it "handles > character" do + input = %{
this > that
} + expected = %{
this > that
} + actual = Loofah.scrub_fragment(input, :escape) + assert_equal(expected, actual.to_html) + end + + it "handles < character" do + input = %{
this < that
} + expected = %{
this < that
} + actual = Loofah.scrub_fragment(input, :escape) + assert_equal(expected, actual.to_html) + end + + it "handles < character in an attribute" do + input = %{
wave
} + expected = %{
wave
} + actual = Loofah.scrub_fragment(input, :escape) + assert_equal(expected, actual.to_html) + end + + it "handles multiple < characters" do + input = %{
this <<
} + expected = %{
this <<
} + actual = Loofah.scrub_fragment(input, :escape) + assert_equal(expected, actual.to_html) + end + + it "handles < entity" do + input = %{
this < that
} + expected = input + actual = Loofah.scrub_fragment(input, :escape) + assert_equal(expected, actual.to_html) + end + end end end