summaryrefslogtreecommitdiff
path: root/app/assets
diff options
context:
space:
mode:
authorRajat Jain <rjain@gitlab.com>2019-09-13 17:53:14 +0530
committerRajat Jain <rjain@gitlab.com>2019-09-13 20:48:52 +0530
commitbc97126e076ad859f18d88403b89573604d49ea7 (patch)
tree11c8e736c3ca9cfdbf466dac6e13802997a49bdb /app/assets
parent25cb337cf12438169f1b14bc5dace8a06a7356e3 (diff)
downloadgitlab-ce-bc97126e076ad859f18d88403b89573604d49ea7.tar.gz
Only render fixed number of mermaid blocks
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/behaviors/markdown/render_mermaid.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/app/assets/javascripts/behaviors/markdown/render_mermaid.js b/app/assets/javascripts/behaviors/markdown/render_mermaid.js
index 27708504791..c3e2c09f1d5 100644
--- a/app/assets/javascripts/behaviors/markdown/render_mermaid.js
+++ b/app/assets/javascripts/behaviors/markdown/render_mermaid.js
@@ -36,6 +36,8 @@ export default function renderMermaid($els) {
securityLevel: 'strict',
});
+ let renderedChars = 0;
+
$els.each((i, el) => {
// Mermaid doesn't like `<br />` tags, so collapse all like tags into `<br>`, which is parsed correctly.
const source = el.textContent.replace(/<br\s*\/>/g, '<br>');
@@ -45,7 +47,7 @@ export default function renderMermaid($els) {
* prevent mermaidjs from hanging up the entire thread and
* causing a DoS.
*/
- if (source && source.length > MAX_CHAR_LIMIT) {
+ if ((source && source.length > MAX_CHAR_LIMIT) || renderedChars > MAX_CHAR_LIMIT) {
el.textContent = sprintf(
__(
'Cannot render the image. Maximum character count (%{charLimit}) has been exceeded.',
@@ -55,6 +57,7 @@ export default function renderMermaid($els) {
return;
}
+ renderedChars += source.length;
// Remove any extra spans added by the backend syntax highlighting.
Object.assign(el, { textContent: source });