| ... | @@ -36,6 +36,8 @@ export default function renderMermaid($els) { |
... | @@ -36,6 +36,8 @@ export default function renderMermaid($els) { |
|
|
securityLevel: 'strict',
|
|
securityLevel: 'strict',
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
let renderedChars = 0;
|
|
|
|
|
|
|
$els.each((i, el) => {
|
|
$els.each((i, el) => {
|
|
|
// Mermaid doesn't like `<br />` tags, so collapse all like tags into `<br>`, which is parsed correctly.
|
|
// 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>');
|
|
const source = el.textContent.replace(/<br\s*\/>/g, '<br>');
|
| ... | @@ -45,7 +47,7 @@ export default function renderMermaid($els) { |
... | @@ -45,7 +47,7 @@ export default function renderMermaid($els) { |
|
|
* prevent mermaidjs from hanging up the entire thread and
|
|
* prevent mermaidjs from hanging up the entire thread and
|
|
|
* causing a DoS.
|
|
* causing a DoS.
|
|
|
*/
|
|
*/
|
|
|
if (source && source.length > MAX_CHAR_LIMIT) {
|
|
if ((source && source.length > MAX_CHAR_LIMIT) || renderedChars > MAX_CHAR_LIMIT) {
|
|
|
el.textContent = sprintf(
|
|
el.textContent = sprintf(
|
|
|
__(
|
|
__(
|
|
|
'Cannot render the image. Maximum character count (%{charLimit}) has been exceeded.',
|
|
'Cannot render the image. Maximum character count (%{charLimit}) has been exceeded.',
|
| ... | @@ -55,6 +57,7 @@ export default function renderMermaid($els) { |
... | @@ -55,6 +57,7 @@ export default function renderMermaid($els) { |
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
renderedChars += source.length;
|
|
|
// Remove any extra spans added by the backend syntax highlighting.
|
|
// Remove any extra spans added by the backend syntax highlighting.
|
|
|
Object.assign(el, { textContent: source });
|
|
Object.assign(el, { textContent: source });
|
|
|
|
|
|
| ... | |
... | |
| ... | | ... | |