Welcome to mirror list, hosted at ThFree Co, Russian Federation.

broadcast_message_sanitization_filter.rb « filter « banzai « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 042293170c86c36981ee6ac8295d83a6bd04cc97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

module Banzai
  module Filter
    # Sanitize HTML produced by Markdown. Allows styling of links and usage of line breaks.
    #
    # Extends Banzai::Filter::BaseSanitizationFilter with specific rules.
    class BroadcastMessageSanitizationFilter < Banzai::Filter::BaseSanitizationFilter
      def customize_whitelist(whitelist)
        whitelist[:elements].push('br')

        whitelist[:attributes]['a'].push('class', 'style')

        whitelist[:css] = { properties: %w(color border background padding margin text-decoration) }

        whitelist
      end
    end
  end
end