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
5304da4e
Commit
5304da4e
authored
Sep 23, 2019
by
Rajat Jain
Committed by
Yorick Peterse
Sep 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only render fixed number of mermaid blocks
parent
9573973c
Changes
3
Expand all
Hide 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 @
5304da4e
...
...
@@ -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 @
5304da4e
---
title
:
Only render fixed number of mermaid blocks
merge_request
:
author
:
type
:
security
spec/features/markdown/mermaid_spec.rb
View file @
5304da4e
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