Sha256: 6328b3a86bbe0a4dfa5f35cce7e0c5366aa522c935cc1f04df2500cb86781315

Contents?: true

Size: 712 Bytes

Versions: 4

Compression:

Stored size: 712 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # Use this class as a scrubber to sanitize admin user input. The default
  # scrubbed provided by Rails does not allow `iframe`s, and we're using
  # them to embed videos, so we need to provide a whole new scrubber.
  #
  # Example:
  #
  #    sanitize(@page.body, scrubber: Decidim::AdminInputScrubber.new)
  #
  # Lists of default tags and attributes are extracted from
  # https://stackoverflow.com/a/35073814/2110884.
  class AdminInputScrubber < UserInputScrubber
    private

    def custom_allowed_attributes
      super + %w(frameborder allowfullscreen) - %w(onerror)
    end

    def custom_allowed_tags
      super + %w(comment iframe)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-core-0.27.2 app/scrubbers/decidim/admin_input_scrubber.rb
decidim-core-0.27.1 app/scrubbers/decidim/admin_input_scrubber.rb
decidim-core-0.27.0 app/scrubbers/decidim/admin_input_scrubber.rb
decidim-core-0.27.0.rc2 app/scrubbers/decidim/admin_input_scrubber.rb