Skip to content

Commit

Permalink
feat: allow all border-collapse CSS property values
Browse files Browse the repository at this point in the history
Closes #201
  • Loading branch information
flavorjones committed Jul 31, 2021
1 parent 78712b5 commit d3b927d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion lib/loofah/html5/safelist.rb
Expand Up @@ -638,6 +638,8 @@ module SafeList
"green",
"groove",
"hidden",
"inherit",
"initial",
"inset",
"italic",
"left",
Expand All @@ -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",
])
Expand Down
28 changes: 28 additions & 0 deletions test/integration/test_ad_hoc.rb
Expand Up @@ -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
<table style='border-collapse: collapse;'></table>
<table style='border-collapse: separate;'></table>
<table style='border-collapse: not-allowed;'></table>
<table style='border-collapse: inherit;'></table>
<table style='border-collapse: initial;'></table>
<table style='border-collapse: revert;'></table>
<table style='border-collapse: unset;'></table>
EOF

expected = <<~EOF
<table style=\"border-collapse:collapse;\"></table>
<table style=\"border-collapse:separate;\"></table>
<table></table>
<table style=\"border-collapse:inherit;\"></table>
<table style=\"border-collapse:initial;\"></table>
<table style=\"border-collapse:revert;\"></table>
<table style=\"border-collapse:unset;\"></table>
EOF

actual = Loofah.scrub_fragment(input, :escape)

assert_equal(expected, actual.to_html)
end
end
end

0 comments on commit d3b927d

Please sign in to comment.