diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 11:10:13 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 11:10:13 +0000 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /app/helpers/markup_helper.rb | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) | |
download | gitlab-ce-0ea3fcec397b69815975647f5e2aa5fe944a8486.tar.gz |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'app/helpers/markup_helper.rb')
-rw-r--r-- | app/helpers/markup_helper.rb | 33 |
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) |