daily pastebin goal
16%
SHARE
TWEET

Untitled

arturaum Jul 12th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # require 'rails/html/scrubbers'
  2. require 'rails-html-sanitizer'
  3.  
  4. module Helpers
  5.   module DefaultScrubbers
  6.  
  7.     # doc = Loofah.fragment(s)
  8.     #              .scrub!(clean_ids_classes)
  9.     #              .scrub!(clean_divs)
  10.     #              .scrub!(clean_font_tags)
  11.  
  12.     def first_scrubber
  13.       scrubber = Rails::Html::PermitScrubber.new
  14.       scrubber.tags = %w(i em b strong u del strike s h1 h2 h3 h4 h5 h6 code blockquote dd abbr
  15.           wbr dl dt img ol ul li p pre sup sub br hr a comment div span table tr th td thead
  16.           tbody article head style title iframe)
  17.       scrubber.attributes = %w(src width height alt name href rel id class)
  18.       scrubber
  19.     end
  20.  
  21.     def clean_scripts
  22.       scrubber = Rails::Html::TargetScrubber.new
  23.       scrubber.tags = %w(script)
  24.       scrubber
  25.     end
  26.  
  27.     def clean_divs
  28.       scrubber = Rails::Html::TargetScrubber.new
  29.       scrubber.tags = %w(div)
  30.       scrubber
  31.     end
  32.  
  33.     def clean_font_tags
  34.       scrubber = Rails::Html::TargetScrubber.new
  35.       scrubber.tags = %w(span i em b strong)
  36.       scrubber
  37.     end
  38.  
  39.     def clean_ids_classes
  40.       scrubber = Rails::Html::TargetScrubber.new
  41.       scrubber.attributes = %w(id class)
  42.       scrubber
  43.     end
  44.  
  45.   end
  46. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top