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

feat: allow all border-collapse CSS property values #214

Merged
merged 1 commit into from Jul 31, 2021
Merged
Show file tree
Hide file tree
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
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