diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-07-04 08:09:34 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-07-04 08:09:34 +0000 |
commit | 4854cfef98d7158bea72b0c29363bf05044e5b67 (patch) | |
tree | f46d4487499bca8951881303a3bcb21427903088 /lib | |
parent | 8678cf9b9c6dfa6cd6bd15822fd901d752c77dc1 (diff) | |
parent | d699362a0931427354a40246b72747837ad85fcb (diff) | |
download | gitlab-ce-4854cfef98d7158bea72b0c29363bf05044e5b67.tar.gz |
Merge branch 'pravi/gitlab-ce-update-html-pipeline' into 'master'
update html-pipeline 2.7.1 -> 2.8
Closes #48571
See merge request gitlab-org/gitlab-ce!20348
Diffstat (limited to 'lib')
-rw-r--r-- | lib/banzai/filter/sanitization_filter.rb | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/lib/banzai/filter/sanitization_filter.rb b/lib/banzai/filter/sanitization_filter.rb index afc2ca4e362..8275bb9e149 100644 --- a/lib/banzai/filter/sanitization_filter.rb +++ b/lib/banzai/filter/sanitization_filter.rb @@ -4,27 +4,20 @@ module Banzai # # Extends HTML::Pipeline::SanitizationFilter with a custom whitelist. class SanitizationFilter < HTML::Pipeline::SanitizationFilter + include Gitlab::Utils::StrongMemoize + UNSAFE_PROTOCOLS = %w(data javascript vbscript).freeze TABLE_ALIGNMENT_PATTERN = /text-align: (?<alignment>center|left|right)/ def whitelist - whitelist = super - - customize_whitelist(whitelist) - - whitelist + strong_memoize(:whitelist) do + customize_whitelist(super.dup) + end end private - def customized?(transformers) - transformers.last.source_location[0] == __FILE__ - end - def customize_whitelist(whitelist) - # Only push these customizations once - return if customized?(whitelist[:transformers]) - # Allow table alignment; we whitelist specific text-align values in a # transformer below whitelist[:attributes]['th'] = %w(style) |