debian-mirror-gitlab/lib/banzai/filter/broadcast_message_sanitization_filter.rb

21 lines
609 B
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# 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
2021-03-08 18:12:59 +05:30
def customize_allowlist(allowlist)
allowlist[:elements].push('br')
2020-01-01 13:55:28 +05:30
2021-03-08 18:12:59 +05:30
allowlist[:attributes]['a'].push('class', 'style')
2020-01-01 13:55:28 +05:30
2021-03-08 18:12:59 +05:30
allowlist[:css] = { properties: %w(color border background padding margin text-decoration) }
2020-01-01 13:55:28 +05:30
2021-03-08 18:12:59 +05:30
allowlist
2020-01-01 13:55:28 +05:30
end
end
end
end