Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
bc97126e
Commit
bc97126e
authored
Sep 13, 2019
by
Rajat Jain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only render fixed number of mermaid blocks
parent
25cb337c
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
1 deletion
+48
-1
app/assets/javascripts/behaviors/markdown/render_mermaid.js
app/assets/javascripts/behaviors/markdown/render_mermaid.js
+4
-1
changelogs/unreleased/security-mermaid-block.yml
changelogs/unreleased/security-mermaid-block.yml
+5
-0
spec/features/markdown/mermaid_spec.rb
spec/features/markdown/mermaid_spec.rb
+39
-0
No files found.
app/assets/javascripts/behaviors/markdown/render_mermaid.js
View file @
bc97126e
...
...
@@ -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
});
...
...
changelogs/unreleased/security-mermaid-block.yml
0 → 100644
View file @
bc97126e
---
title
:
Only render fixed number of mermaid blocks
merge_request
:
author
:
type
:
security
spec/features/markdown/mermaid_spec.rb
View file @
bc97126e
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment