-
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #200 from flavorjones/199-css-functions-not-handle…
…d-properly fix: handle CSS functions in a CSS shorthand property
- Loading branch information
Showing
5 changed files
with
77 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
require "helper" | ||
|
||
class UnitHTML5Scrub < Loofah::TestCase | ||
include Loofah | ||
|
||
describe "hex values" do | ||
it "handles upper case" do | ||
assert_equal "background:#ABC012;", Loofah::HTML5::Scrub.scrub_css("background: #ABC012") | ||
end | ||
it "handles lower case" do | ||
assert_equal "background:#abc012;", Loofah::HTML5::Scrub.scrub_css("background: #abc012") | ||
end | ||
end | ||
|
||
describe "css functions" do | ||
it "allows safe functions" do | ||
assert_equal "background-color:linear-gradient(transparent 50%, #ffff66 50%);", | ||
Loofah::HTML5::Scrub.scrub_css("background-color: linear-gradient(transparent 50%, #ffff66 50%);") | ||
end | ||
|
||
it "disallows unsafe functions" do | ||
assert_equal "", Loofah::HTML5::Scrub.scrub_css("background-color: haxxor-fun(transparent 50%, #ffff66 50%);") | ||
end | ||
|
||
# see #199 for the bug we're testing here | ||
it "allows safe functions in shorthand css properties" do | ||
assert_equal "background:linear-gradient(transparent 50%, #ffff66 50%);", | ||
Loofah::HTML5::Scrub.scrub_css("background: linear-gradient(transparent 50%, #ffff66 50%);") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters