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

#allowlist, remove_rel

Methods included from Gitlab::Utils::SanitizeNodeLink

#remove_unsafe_links, #safe_protocol?, #sanitize_unsafe_links

Instance Method Details

#customize_allowlist(allowlist) ⇒ Object



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

def customize_allowlist(allowlist)
  allowlist[:elements].push('br')

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

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

  allowlist
end