Commit 5431af8b authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch...

Merge branch '62116-performance-issue-502-errors-on-rendering-of-issues-with-heavy-markdown-contents' into 'master'

Resolve "Performance issue: 502 errors on rendering of issues with heavy markdown contents"

Closes #62116

See merge request gitlab-org/gitlab-ce!28597
parents 20375f81 f9f91472
# coding: utf-8
# frozen_string_literal: true # frozen_string_literal: true
module PageLayoutHelper module PageLayoutHelper
...@@ -36,7 +37,7 @@ module PageLayoutHelper ...@@ -36,7 +37,7 @@ module PageLayoutHelper
if description.present? if description.present?
@page_description = description.squish @page_description = description.squish
elsif @page_description.present? elsif @page_description.present?
sanitize(@page_description, tags: []).truncate_words(30) sanitize(@page_description.truncate_words(30), tags: [])
end end
end end
......
---
title: Fix performance issue with large Markdown content in issue or merge request
description
merge_request: 28597
author:
type: performance
...@@ -38,6 +38,14 @@ describe PageLayoutHelper do ...@@ -38,6 +38,14 @@ describe PageLayoutHelper do
expect(helper.page_description).to eq 'Bold Header' expect(helper.page_description).to eq 'Bold Header'
end end
it 'truncates before sanitizing' do
helper.page_description('<b>Bold</b> <img> <img> <img> <h1>Header</h1> ' * 10)
# 12 words because <img> was counted as a word
expect(helper.page_description)
.to eq('Bold Header Bold Header Bold Header Bold Header Bold Header Bold Header...')
end
end end
describe 'page_image' do describe 'page_image' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment