Sha256: 4efc5c1a1e8fe097bb7d87ea96617abe354d8c09d04bb8c27cdfe29107b5a209

Contents?: true

Size: 895 Bytes

Versions: 7

Compression:

Stored size: 895 Bytes

Contents

module WhiteListHelper

  def self.mattr_accessor_with_default(name, value = nil)
    mattr_accessor name
    self.send("#{name}=", value) if value
  end

  mattr_accessor_with_default :settings, {
      :elements => %w[ a blockquote del ins strong em b i p sub sup small hr br div span h1 h2 h3 h4 h5 h6 ul ol li img u strike object param embed iframe ],
      :attributes => {
        'a'          => %w[href],
        'img'        => %w[src width height alt title],
        'blockquote' => %w[cite],
        'del'        => %w[cite datetime],
        'ins'        => %w[cite datetime],
        :all         => %w[id class style align]
      },
      :protocols  => {
        'a' => {'href' => ['http', 'https', 'mailto', :relative]},
        'img' => {'src'  => ['http', 'https', :relative]}
      }
    }

  def white_list(html)
    Sanitize.clean(html, WhiteListHelper.settings)
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
community_engine-3.2.0 lib/white_list/white_list_helper.rb
community_engine-3.0.0 lib/white_list/white_list_helper.rb
community_engine-2.3.2 vendor/plugins/white_list/lib/white_list_helper.rb
community_engine-2.3.1 vendor/plugins/white_list/lib/white_list_helper.rb
community_engine-2.3.0 vendor/plugins/white_list/lib/white_list_helper.rb
community_engine-2.1.0 vendor/plugins/white_list/lib/white_list_helper.rb
community_engine-2.0.0 vendor/plugins/white_list/lib/white_list_helper.rb