Last active
April 20, 2023 19:33
-
-
Save ivan-kolmychek/ee2fdc53f3e2c637271d to your computer and use it in GitHub Desktop.
Rails 4: scrubber with customizeable lists of allowed tags and attributes, based on :strip from Loofah gem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
... | |
def sanitize(string, options) | |
Loofah.fragment(string).scrub!(AllowedTagsScrubber.new(options)).to_s | |
end | |
... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# place this file to config/initializers/ directory | |
Rails.application.config.autoload_paths += [ Rails.root.join('app', 'scrubbers') ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment