From d3b927dbf4e7cde85b6feaca9f5f41014fcb26a7 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sat, 31 Jul 2021 17:20:04 -0400 Subject: [PATCH] feat: allow all `border-collapse` CSS property values Closes #201 --- CHANGELOG.md | 1 + lib/loofah/html5/safelist.rb | 7 ++++++- test/integration/test_ad_hoc.rb | 28 ++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c78bee0..2d044a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Features * Allow HTML5 element `wbr`. +* Allow all CSS property values for `border-collapse`. [[#201](https://github.com/flavorjones/loofah/issues/201)] ### Changes diff --git a/lib/loofah/html5/safelist.rb b/lib/loofah/html5/safelist.rb index 583ea8c..1bde02c 100644 --- a/lib/loofah/html5/safelist.rb +++ b/lib/loofah/html5/safelist.rb @@ -638,6 +638,8 @@ module SafeList "green", "groove", "hidden", + "inherit", + "initial", "inset", "italic", "left", @@ -653,16 +655,19 @@ module SafeList "pointer", "purple", "red", + "revert", "ridge", "right", + "separate", "silver", "solid", "teal", - "thin", "thick", + "thin", "top", "transparent", "underline", + "unset", "white", "yellow", ]) diff --git a/test/integration/test_ad_hoc.rb b/test/integration/test_ad_hoc.rb index 5308ecd..356e8d1 100644 --- a/test/integration/test_ad_hoc.rb +++ b/test/integration/test_ad_hoc.rb @@ -287,5 +287,33 @@ def test_dont_remove_whitespace_between_tags assert_equal(expected, actual.to_html) end + + it "allows border-collapse property values" do + # https://github.com/flavorjones/loofah/issues/201 + # https://developer.mozilla.org/en-US/docs/Web/CSS/border-collapse + input = <<~EOF +
+
+
+
+
+
+
+ EOF + + expected = <<~EOF +
+
+
+
+
+
+
+ EOF + + actual = Loofah.scrub_fragment(input, :escape) + + assert_equal(expected, actual.to_html) + end end end