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

Would it be possible and safe to whitelist some CSS functions? #122

Closed
NikoRoberts opened this issue Sep 20, 2017 · 3 comments
Closed

Would it be possible and safe to whitelist some CSS functions? #122

NikoRoberts opened this issue Sep 20, 2017 · 3 comments

Comments

@NikoRoberts
Copy link
Contributor

NikoRoberts commented Sep 20, 2017

At the moment scrub_css will drop an entire inline style attribute if a CSS function is used.

For example:

# ruby 2.3.3
# loofah 2.0.3
2.3.3 :001 > Loofah.fragment("<div style='background-color: red;'></div>").scrub!(:strip).to_html
 => "<div style=\"background-color: red;\"></div>" 
2.3.3 :002 > Loofah.fragment("<div style='background-color: red; margin-left: calc(100% - 4em)'></div>").scrub!(:strip).to_html
 => "<div></div>" 

Is there a situation where whitelisting calc would be a bad idea?

@oluwayetty
Copy link

oluwayetty commented Sep 20, 2017

My team is also currently stuck on a whitelisting issue for the attribute list-style-type.
And apparently from this link, it's also not included and I'm wondering if one PR can be raised to include these attributes that are needed for other projects but not included.

@flavorjones
Copy link
Owner

Generally speaking, I think the right thing to do is to make it easier/possible to extend what's whitelisted by Loofah. Many people have asked for tags, attributes or functions to be whitelisted, and honestly I'd rather the core library be as conservative as possible and force users to opt into additional non-obvious tags/attributes/functions.

flavorjones added a commit that referenced this issue Feb 6, 2018
Added ability to whitelist particular functions #122
@flavorjones
Copy link
Owner

Merged pull request, this will be in the next release, planned to be 2.2.0 this weekend.

flavorjones added a commit that referenced this issue Feb 11, 2018
[fixes #129]
[related to #122]
[related to #123]
@flavorjones flavorjones modified the milestone: v2.3.0 Oct 28, 2018
flavorjones added a commit that referenced this issue Oct 28, 2018
still omit `url` and `image`

related to #122 and #123
also see #143
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants