-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
CSS Scrubber is removing the builtin extended CSS color properties in >= v2.9.0
#243
Comments
Hi, thanks for reporting this. For clarity, I think this is what you're saying is happening? (The code snippets above are inconsistent so I just want to make sure I understand.) #! /usr/bin/env ruby
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "loofah", "= 2.8.0"
end
Loofah.fragment('<div style="background-color: blue;">Test</div>').scrub!(:strip).to_s
# => "<div style=\"background-color: blue;\">Test</div>"
Loofah.fragment('<div style="background-color: lightblue;">Test</div>').scrub!(:strip).to_s
# => "<div style=\"background-color: lightblue;\">Test</div>" #! /usr/bin/env ruby
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "loofah", "= 2.18.0"
end
Loofah.fragment('<div style="background-color: blue;">Test</div>').scrub!(:strip).to_s
# => "<div style=\"background-color:blue;\">Test</div>"
Loofah.fragment('<div style="background-color: lightblue;">Test</div>').scrub!(:strip).to_s
# => "<div>Test</div>" and we expect that I'll investigate! |
Looks like we just need to include the extended colors in #! /usr/bin/env ruby
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "loofah", "= 2.18.0"
end
Loofah.fragment('<div style="background-color: lightblue;">Test</div>').scrub!(:strip).to_s
# => "<div>Test</div>"
Loofah::HTML5::SafeList::ACCEPTABLE_CSS_KEYWORDS.add("lightblue")
Loofah.fragment('<div style="background-color: lightblue;">Test</div>').scrub!(:strip).to_s
# => "<div style=\"background-color:lightblue;\">Test</div>" So you have a workaround right now if you need it. I'll schedule some work to add those colors and make a new release. |
See #244 |
Thanks a bunch @flavorjones!! The quick turn around is SUPER appreciated!!! |
v2.19.0 has been shipped! Happy hacking |
https://build.opensuse.org/request/show/1010074 by user coolo + dimstar_suse updated to version 2.19.0 see installed CHANGELOG.md ## 2.19.0 / 2022-09-14 ### Features * Allow SVG 1.0 color keyword names in CSS attributes. These colors are part of the [CSS Color Module Level 3](https://www.w3.org/TR/css-color-3/#svg-color) recommendation released 2022-01-18. [[#243](flavorjones/loofah#243)]
Expected
When scrubbing HTML which makes use of the builtin extended CSS color properties in the
style
property they are not removed.Actual
Builtin extended CSS color properties included in the
style
property of HTML strings are being removed.Reproduction steps
The issue looks to be introduced in v2.9.0
Loofah.fragment('<div style="background-color: blue;">Test</div>').scrub!(:strip).to_s
<div style=\"background:blue;\">Test</div>
Loofah.fragment('<div style="background-color: lightblue;">Test</div>').scrub!(:strip).to_s
<div style=\"background-color: lightblue;\">Test</div>
>= 2.9.0
Loofah.fragment('<div style="background-color: blue;">Test</div>').scrub!(:strip).to_s
<div style=\"background:blue;\">Test</div>
Loofah.fragment('<div style="background-color: lightblue;">Test</div>').scrub!(:strip).to_s
<div>Test</div>
<div style="background-color: lightblue;">Test</div>
The text was updated successfully, but these errors were encountered: