diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-25 16:30:40 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-25 16:30:40 +0000 |
commit | b485c8c3723dc5aaba15ab9fa258010d1ec66d61 (patch) | |
tree | 36cd2260b2f31bc77ad313b644e5784160ce9104 /lib | |
parent | 479d579719c36f1b8706165c20f4525bc32bb451 (diff) | |
download | gitlab-ce-b485c8c3723dc5aaba15ab9fa258010d1ec66d61.tar.gz |
Add latest changes from gitlab-org/security/gitlab@14-8-stable-ee
Diffstat (limited to 'lib')
-rw-r--r-- | lib/banzai/filter/math_filter.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/banzai/filter/math_filter.rb b/lib/banzai/filter/math_filter.rb index 6859d67c9d8..0ac506776be 100644 --- a/lib/banzai/filter/math_filter.rb +++ b/lib/banzai/filter/math_filter.rb @@ -25,7 +25,14 @@ module Banzai DOLLAR_SIGN = '$' + # Limit to how many nodes can be marked as math elements. + # Prevents timeouts for large notes. + # For more information check: https://gitlab.com/gitlab-org/gitlab/-/issues/341832 + RENDER_NODES_LIMIT = 50 + def call + nodes_count = 0 + doc.xpath(XPATH_CODE).each do |code| closing = code.next opening = code.previous @@ -41,6 +48,9 @@ module Banzai code[STYLE_ATTRIBUTE] = 'inline' closing.content = closing.content[1..] opening.content = opening.content[0..-2] + + nodes_count += 1 + break if nodes_count >= RENDER_NODES_LIMIT end end |