Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # require 'rails/html/scrubbers'
- require 'rails-html-sanitizer'
- module Helpers
- module DefaultScrubbers
- # doc = Loofah.fragment(s)
- # .scrub!(clean_ids_classes)
- # .scrub!(clean_divs)
- # .scrub!(clean_font_tags)
- def first_scrubber
- scrubber = Rails::Html::PermitScrubber.new
- scrubber.tags = %w(i em b strong u del strike s h1 h2 h3 h4 h5 h6 code blockquote dd abbr
- wbr dl dt img ol ul li p pre sup sub br hr a comment div span table tr th td thead
- tbody article head style title iframe)
- scrubber.attributes = %w(src width height alt name href rel id class)
- scrubber
- end
- def clean_scripts
- scrubber = Rails::Html::TargetScrubber.new
- scrubber.tags = %w(script)
- scrubber
- end
- def clean_divs
- scrubber = Rails::Html::TargetScrubber.new
- scrubber.tags = %w(div)
- scrubber
- end
- def clean_font_tags
- scrubber = Rails::Html::TargetScrubber.new
- scrubber.tags = %w(span i em b strong)
- scrubber
- end
- def clean_ids_classes
- scrubber = Rails::Html::TargetScrubber.new
- scrubber.attributes = %w(id class)
- scrubber
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement