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

Add CSS functions whitelisting example to README #143

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ end
Loofah.xml_document(File.read('plague.xml')).scrub!(bring_out_your_dead)
```

=== Built-In HTML Scrubbers
### Built-In HTML Scrubbers

Loofah comes with a set of sanitizing scrubbers that use HTML5lib's
whitelist algorithm:
Expand Down Expand Up @@ -275,6 +275,22 @@ Loofah.xml_document(bad_xml).scrub!(custom_scrubber)
```


### Whitelisting CSS functions

Loofah by default whitelists only two CSS functions: `calc` and `rgb`
(see [#123](https://github.com/flavorjones/loofah/pull/123)). You can whitelist additional
CSS functions in the following way:

```ruby
Loofah::HTML5::WhiteList::ACCEPTABLE_CSS_FUNCTIONS.merge Set.new(%w[
calc rgb rgba hsl hsla opacity
rotate rotate3d rotateX rotateY rotateZ
scale scale3d scaleX scaleY scaleZ
translate translate3d translateX translateY translateZ
])
```


### View Helpers

Loofah has two "view helpers": Loofah::Helpers.sanitize and
Expand Down