Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
condenser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
condenser
Commits
c793efd8
Commit
c793efd8
authored
4 years ago
by
Quoc Huy Nguyen Dinh
Browse files
Options
Downloads
Patches
Plain Diff
Fix bug crashing the page when adding <script> tag only in the post editor
parent
bc2ed84d
No related branches found
Branches containing commit
No related tags found
2 merge requests
!343
- gray out negative rshares comment and don't render the markdown
,
!341
Resolve "Consider adding highlights for code blocks"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/components/cards/MarkdownViewer.jsx
+4
-1
4 additions, 1 deletion
src/app/components/cards/MarkdownViewer.jsx
src/shared/HtmlReady.js
+9
-3
9 additions, 3 deletions
src/shared/HtmlReady.js
with
13 additions
and
4 deletions
src/app/components/cards/MarkdownViewer.jsx
+
4
−
1
View file @
c793efd8
...
...
@@ -123,7 +123,10 @@ class MarkdownViewer extends Component {
}
// Needs to be done here so that the tags added by HighlightJS won't be filtered of by the sanitizer
cleanText
=
highlightCodes
(
cleanText
).
html
;
const
higlightedText
=
highlightCodes
(
cleanText
).
html
;
if
(
higlightedText
)
{
cleanText
=
higlightedText
;
}
const
noImageActive
=
cleanText
.
indexOf
(
noImageText
)
!==
-
1
;
...
...
This diff is collapsed.
Click to expand it.
src/shared/HtmlReady.js
+
9
−
3
View file @
c793efd8
...
...
@@ -146,10 +146,16 @@ function traverseForCodeHighlight(node, depth = 0) {
}
export
function
highlightCodes
(
html
)
{
const
doc
=
DOMParser
.
parseFromString
(
html
,
'
text/html
'
);
traverseForCodeHighlight
(
doc
);
if
(
html
.
match
(
/<code>.*
?
<
\/
code>/
s
))
{
const
doc
=
DOMParser
.
parseFromString
(
html
,
'
text/html
'
);
traverseForCodeHighlight
(
doc
);
return
{
html
:
doc
?
XMLSerializer
.
serializeToString
(
doc
)
:
''
,
};
}
return
{
html
:
doc
?
XMLSerializer
.
serializeToString
(
doc
)
:
''
,
html
:
null
,
};
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment