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

Implement custom scrubber for Alchemy::Ingredients::Richtext #2700

Closed
wants to merge 2 commits into from

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Jan 19, 2024

What is this pull request for?

We found that using Rails' HTML sanitizer does more than we want the Richtext sanitization to do: It does not just remove nodes that are not in the safelist, it also escapes some markup (especially in links).

This introduces a custom Loofah "scrubber" that only cares about the element safelist.

The sanitized_body attribute is not for escaping at the view layer, where all these safety precautions are necessary, but just for making sure admin's don't use iframes when we don't want to.

See the following related issues and commits:
rails/rails-html-sanitizer@f3ba1a8 sparklemotion/nokogiri#3104 sparklemotion/nokogiri#969 (comment) flavorjones/loofah#14 (comment)

Checklist

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have added tests to cover this change

@mamhoff mamhoff marked this pull request as draft January 19, 2024 18:24
We found that using Rails' HTML sanitizer does more than we want the
Richtext sanitization to do: It does not just remove nodes that are not
in the safelist, it also escapes some markup (especially in links).

This introduces a custom Loofah "scrubber" that only cares about the
element safelist.

The `sanitized_body` attribute is not for escaping at the view layer,
where all these safety precautions are necessary, but just for making
sure admin's don't use iframes when we don't want to.

See the following related issues and commits:
rails/rails-html-sanitizer@f3ba1a8
sparklemotion/nokogiri#3104
sparklemotion/nokogiri#969 (comment)
flavorjones/loofah#14 (comment)
@mamhoff mamhoff marked this pull request as ready for review January 19, 2024 22:24
@mamhoff
Copy link
Contributor Author

mamhoff commented Jan 22, 2024

Closing in favor of #2702 . Props to @tvdeyen for knowing early-on that that's the way to go.

@mamhoff mamhoff closed this Jan 22, 2024
@mamhoff mamhoff deleted the custom-scrubber branch January 22, 2024 13:52
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

Successfully merging this pull request may close these issues.

1 participant