diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 18:18:33 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 18:18:33 +0000 |
commit | f64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch) | |
tree | a2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /lib/banzai | |
parent | bfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff) | |
download | gitlab-ce-f64a639bcfa1fc2bc89ca7db268f594306edfd7c.tar.gz |
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'lib/banzai')
-rw-r--r-- | lib/banzai/filter/autolink_filter.rb | 2 | ||||
-rw-r--r-- | lib/banzai/filter/gollum_tags_filter.rb | 2 | ||||
-rw-r--r-- | lib/banzai/filter/markdown_pre_escape_filter.rb | 6 | ||||
-rw-r--r-- | lib/banzai/filter/sanitization_filter.rb | 8 | ||||
-rw-r--r-- | lib/banzai/filter/spaced_link_filter.rb | 2 | ||||
-rw-r--r-- | lib/banzai/filter/video_link_filter.rb | 2 |
6 files changed, 13 insertions, 9 deletions
diff --git a/lib/banzai/filter/autolink_filter.rb b/lib/banzai/filter/autolink_filter.rb index 0aa1ee8f604..d569711431c 100644 --- a/lib/banzai/filter/autolink_filter.rb +++ b/lib/banzai/filter/autolink_filter.rb @@ -120,7 +120,7 @@ module Banzai end def autolink_filter(text) - Gitlab::StringRegexMarker.new(CGI.unescapeHTML(text), text.html_safe).mark(LINK_PATTERN) do |link, left:, right:| + Gitlab::StringRegexMarker.new(CGI.unescapeHTML(text), text.html_safe).mark(LINK_PATTERN) do |link, left:, right:, mode:| autolink_match(link).html_safe end end diff --git a/lib/banzai/filter/gollum_tags_filter.rb b/lib/banzai/filter/gollum_tags_filter.rb index e16de13725f..8a7d3c49ffb 100644 --- a/lib/banzai/filter/gollum_tags_filter.rb +++ b/lib/banzai/filter/gollum_tags_filter.rb @@ -100,7 +100,7 @@ module Banzai if url?(content) path = content - elsif file = wiki.find_file(content) + elsif file = wiki.find_file(content, load_content: false) path = ::File.join(wiki_base_path, file.path) end diff --git a/lib/banzai/filter/markdown_pre_escape_filter.rb b/lib/banzai/filter/markdown_pre_escape_filter.rb index 9fd77c48659..bedc2d0fd04 100644 --- a/lib/banzai/filter/markdown_pre_escape_filter.rb +++ b/lib/banzai/filter/markdown_pre_escape_filter.rb @@ -24,8 +24,10 @@ module Banzai # This filter does the initial surrounding, and MarkdownPostEscapeFilter # does the conversion into span tags. class MarkdownPreEscapeFilter < HTML::Pipeline::TextFilter - ASCII_PUNCTUATION = %r{([\\][!"#$%&'()*+,-./:;<=>?@\[\\\]^_`{|}~])}.freeze - LITERAL_KEYWORD = 'cmliteral' + # We just need to target those that are special GitLab references + REFERENCE_CHARACTERS = '@#!$&~%^' + ASCII_PUNCTUATION = %r{([\\][#{REFERENCE_CHARACTERS}])}.freeze + LITERAL_KEYWORD = 'cmliteral' def call return @text unless Feature.enabled?(:honor_escaped_markdown, context[:group] || context[:project]&.group) diff --git a/lib/banzai/filter/sanitization_filter.rb b/lib/banzai/filter/sanitization_filter.rb index f6314040f28..06dddc74eba 100644 --- a/lib/banzai/filter/sanitization_filter.rb +++ b/lib/banzai/filter/sanitization_filter.rb @@ -12,8 +12,8 @@ module Banzai def customize_allowlist(allowlist) # Allow table alignment; we allow specific text-align values in a # transformer below - allowlist[:attributes]['th'] = %w(style) - allowlist[:attributes]['td'] = %w(style) + allowlist[:attributes]['th'] = %w[style] + allowlist[:attributes]['td'] = %w[style] allowlist[:css] = { properties: ['text-align'] } # Allow the 'data-sourcepos' from CommonMark on all elements @@ -25,7 +25,7 @@ module Banzai # Allow `id` in a and li elements for footnotes # and remove any `id` properties not matching for footnotes allowlist[:attributes]['a'].push('id') - allowlist[:attributes]['li'] = %w(id) + allowlist[:attributes]['li'] = %w[id] allowlist[:transformers].push(self.class.remove_non_footnote_ids) allowlist @@ -64,3 +64,5 @@ module Banzai end end end + +Banzai::Filter::SanitizationFilter.prepend_if_ee('EE::Banzai::Filter::SanitizationFilter') diff --git a/lib/banzai/filter/spaced_link_filter.rb b/lib/banzai/filter/spaced_link_filter.rb index 101b55a49e4..f52ffe117d9 100644 --- a/lib/banzai/filter/spaced_link_filter.rb +++ b/lib/banzai/filter/spaced_link_filter.rb @@ -76,7 +76,7 @@ module Banzai end def spaced_link_filter(text) - Gitlab::StringRegexMarker.new(CGI.unescapeHTML(text), text.html_safe).mark(LINK_OR_IMAGE_PATTERN) do |link, left:, right:| + Gitlab::StringRegexMarker.new(CGI.unescapeHTML(text), text.html_safe).mark(LINK_OR_IMAGE_PATTERN) do |link, left:, right:, mode:| spaced_link_match(link).html_safe end end diff --git a/lib/banzai/filter/video_link_filter.rb b/lib/banzai/filter/video_link_filter.rb index 98987ee2019..3789a215dd8 100644 --- a/lib/banzai/filter/video_link_filter.rb +++ b/lib/banzai/filter/video_link_filter.rb @@ -15,7 +15,7 @@ module Banzai end def extra_element_attrs - { width: "400" } + { width: "400", preload: "metadata" } end end end |