Sha256: 8029d527497f57f06878ecdc3d418079e2752468c7ea7391cd154dda5d254998

Contents?: true

Size: 1.19 KB

Versions: 18

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module Decidim
  # Helper that provides methods to render order selector and links
  module SanitizeHelper
    def self.included(base)
      base.include ActionView::Helpers::SanitizeHelper
    end

    # Public: It sanitizes a user-inputted string with the
    # `Decidim::UserInputScrubber` scrubber, so that video embeds work
    # as expected. Uses Rails' `sanitize` internally.
    #
    # html - A string representing user-inputted HTML.
    #
    # Returns an HTML-safe String.
    def decidim_sanitize(html, options = {})
      if options[:strip_tags]
        strip_tags sanitize(html, scrubber: Decidim::UserInputScrubber.new)
      else
        sanitize(html, scrubber: Decidim::UserInputScrubber.new)
      end
    end

    def decidim_sanitize_newsletter(html, options = {})
      if options[:strip_tags]
        strip_tags sanitize(html, scrubber: Decidim::NewsletterScrubber.new)
      else
        sanitize(html, scrubber: Decidim::NewsletterScrubber.new)
      end
    end

    def decidim_html_escape(text)
      ERB::Util.unwrapped_html_escape(text.to_str)
    end

    def decidim_url_escape(text)
      decidim_html_escape(text).sub(/^javascript:/, "")
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
decidim-core-0.25.2 app/helpers/decidim/sanitize_helper.rb
decidim-core-0.25.1 app/helpers/decidim/sanitize_helper.rb
decidim-core-0.25.0 app/helpers/decidim/sanitize_helper.rb
decidim-core-0.25.0.rc4 app/helpers/decidim/sanitize_helper.rb
decidim-core-0.25.0.rc3 app/helpers/decidim/sanitize_helper.rb
decidim-core-0.25.0.rc2 app/helpers/decidim/sanitize_helper.rb
decidim-core-0.25.0.rc1 app/helpers/decidim/sanitize_helper.rb
decidim-core-0.24.3 app/helpers/decidim/sanitize_helper.rb
decidim-core-0.23.6 app/helpers/decidim/sanitize_helper.rb
decidim-core-0.24.2 app/helpers/decidim/sanitize_helper.rb
decidim-core-0.23.5 app/helpers/decidim/sanitize_helper.rb
decidim-core-0.24.1 app/helpers/decidim/sanitize_helper.rb
decidim-core-0.24.0 app/helpers/decidim/sanitize_helper.rb
decidim-core-0.24.0.rc2 app/helpers/decidim/sanitize_helper.rb
decidim-core-0.23.4 app/helpers/decidim/sanitize_helper.rb
decidim-core-0.24.0.rc1 app/helpers/decidim/sanitize_helper.rb
decidim-core-0.23.3 app/helpers/decidim/sanitize_helper.rb
decidim-core-0.23.2 app/helpers/decidim/sanitize_helper.rb