Skip to content
Permalink
Browse files

AO3-4080 Fix CSS regex to support shadow box fully (#3351)

* AO3-4080 Fix css regex to support shadow box fully

* AO3-4080 Remove todo comment

* AO3-4080 Move test for box shadow
  • Loading branch information
hatal175 authored and sarken committed Oct 17, 2019
1 parent df63db3 commit 2ff9cebf7a92f442e98e8c9874e8b50ca2c7f448
Showing with 5 additions and 9 deletions.
  1. +1 −1 lib/css_cleaner.rb
  2. +4 −8 spec/models/skin_spec.rb
@@ -202,7 +202,7 @@ def sanitize_css_value(value)
value_stripped = value.downcase.gsub(/(!important)/, '').strip

# if it's a comma-separated set of valid values it's fine
return value if value_stripped =~ /^(#{VALUE_REGEX}\,?)+$/i
return value if value_stripped =~ /^(#{VALUE_REGEX}\,?\s*)+$/i

# If it's explicitly in our keywords it's fine
return value if value_stripped.split(',').all? {|subval| ArchiveConfig.SUPPORTED_CSS_KEYWORDS.include?(subval.strip)}
@@ -106,21 +106,17 @@
background:-ms-linear-gradient(top,#fafafa,#ddd);
background:-o-linear-gradient(top,#fafafa,#ddd);
background:linear-gradient(top,#fafafa,#ddd);
color:#555 }"
color:#555 }",

"saves box shadows with multiple shadows" =>
"li { box-shadow: 5px 5px 5px black, inset 0 0 0 1px #dadada; }"
}.each_pair do |condition, css|
it condition do
@skin.css = css
expect(@skin.save).to be_truthy
end
end

# This is verified to work in prod and staging, but not dev
# TODO: fix across environments?
xit "should save CSS3 box shadows with multiple shadows" do
@skin.css = "li { box-shadow: 5px 5px 5px black, inset 0 0 0 1px #dadada; }"
expect(@skin.save).to be_truthy
end

# bad bad bad css
{
"should not save garbage with braces" => "blhalkdfasd {ljaflkasjdflasd}",

0 comments on commit 2ff9ceb

Please sign in to comment.
You can’t perform that action at this time.