Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/markup_helper.rb')
-rw-r--r--app/helpers/markup_helper.rb33
1 files changed, 25 insertions, 8 deletions
diff --git a/app/helpers/markup_helper.rb b/app/helpers/markup_helper.rb
index 7a4cc61af79..777d485797f 100644
--- a/app/helpers/markup_helper.rb
+++ b/app/helpers/markup_helper.rb
@@ -6,6 +6,12 @@ module MarkupHelper
include ActionView::Helpers::TextHelper
include ActionView::Context
+ # Let's increase the render timeout
+ # For a smaller one, a test that renders the blob content statically fails
+ # We can consider removing this custom timeout when refactor_blob_viewer FF is removed:
+ # https://gitlab.com/gitlab-org/gitlab/-/issues/324351
+ RENDER_TIMEOUT = 5.seconds
+
def plain?(filename)
Gitlab::MarkupHelper.plain?(filename)
end
@@ -88,7 +94,10 @@ module MarkupHelper
text,
tags: tags,
attributes: Rails::Html::WhiteListSanitizer.allowed_attributes +
- %w(style data-src data-name data-unicode-version data-iid data-project-path data-mr-title data-html)
+ %w(
+ style data-src data-name data-unicode-version data-html
+ data-reference-type data-project-path data-iid data-mr-title
+ )
)
# since <img> tags are stripped, this can leave empty <a> tags hanging around
@@ -136,14 +145,22 @@ module MarkupHelper
def markup_unsafe(file_name, text, context = {})
return '' unless text.present?
- if gitlab_markdown?(file_name)
- markdown_unsafe(text, context)
- elsif asciidoc?(file_name)
- asciidoc_unsafe(text, context)
- elsif plain?(file_name)
- plain_unsafe(text)
+ markup = proc do
+ if gitlab_markdown?(file_name)
+ markdown_unsafe(text, context)
+ elsif asciidoc?(file_name)
+ asciidoc_unsafe(text, context)
+ elsif plain?(file_name)
+ plain_unsafe(text)
+ else
+ other_markup_unsafe(file_name, text, context)
+ end
+ end
+
+ if Feature.enabled?(:markup_rendering_timeout, @project)
+ Gitlab::RenderTimeout.timeout(foreground: RENDER_TIMEOUT, &markup)
else
- other_markup_unsafe(file_name, text, context)
+ markup.call
end
rescue StandardError => e
Gitlab::ErrorTracking.track_exception(e, project_id: @project&.id, file_name: file_name)