Class: Banzai::Filter::BroadcastMessageSanitizationFilter

Inherits:
BaseSanitizationFilter
  • Object
show all
Defined in:
lib/banzai/filter/broadcast_message_sanitization_filter.rb

Overview

Sanitize HTML produced by Markdown. Allows styling of links and usage of line breaks.

Extends Banzai::Filter::BaseSanitizationFilter with specific rules.

Constant Summary

Constants inherited from BaseSanitizationFilter

Banzai::Filter::BaseSanitizationFilter::UNSAFE_PROTOCOLS

Constants included from Gitlab::Utils::SanitizeNodeLink

Gitlab::Utils::SanitizeNodeLink::ATTRS_TO_SANITIZE, Gitlab::Utils::SanitizeNodeLink::UNSAFE_PROTOCOLS

Instance Method Summary collapse

Methods inherited from BaseSanitizationFilter

remove_rel, #whitelist

Methods included from Gitlab::Utils::SanitizeNodeLink

#remove_unsafe_links, #safe_protocol?

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Instance Method Details

#customize_whitelist(whitelist) ⇒ Object


9
10
11
12
13
14
15
16
17
# File 'lib/banzai/filter/broadcast_message_sanitization_filter.rb', line 9

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