Skip to content

Commit

Permalink
Merge pull request #214 from flavorjones/201-border-collapse
Browse files Browse the repository at this point in the history
feat: allow all `border-collapse` CSS property values
  • Loading branch information
flavorjones authored Jul 31, 2021
2 parents 78712b5 + d3b927d commit 23b756c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 23b756c

Please sign in to comment.