-
Notifications
You must be signed in to change notification settings - Fork 46
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
Hook to sanitize style
contents
#179
Comments
This would be a great plus for Python users moving from the now-deprecated bleach, and it would allow for better integration with things like CKEditor. |
I'm not opposed to a Also, it should default to only allowing a small number of very safe options, like italics, bold, and color. No margins, since negative margins could be used for clickjacking. |
Unfortunately although I would love to see a style sanitizer, I don't really have the time to implement it at this point, so I'm just being content with fewer features of CKEditor for now. A quick search on crates.io turns up I suppose an implementation would involve parsing the CSS with a spec-compliant parser, running over the AST with a user-defined whitelist, and outputting the CSS again into the HTML element's style attribute. |
Looking at bleach's css sanitizer it whitelists on the property name alone so being able to run on the raw AST is probably not necessary as long as you can run on and serialize individual declarations. Also in the list parcel_css seems to be the old name for lightningcss, the readme is strikingly similar, it hasn't been updated in two years, and lightning advertises itself as Parcel's CSS parser. |
Finally found the time to give this a a shot: #208 |
I don't know whether Ammonia would want to bundle a CSS sanitizer, but the ability to handle that somewhat finely without needing to resort to a full-blown
attribute_filter
would be nice.The text was updated successfully, but these errors were encountered: