Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
7670c953
Unverified
Commit
7670c953
authored
Dec 31, 2022
by
boojack
Committed by
GitHub
Dec 31, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: fix XSS in renderer (#880)
parent
65e9fdea
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
4 deletions
+8
-4
Bold.ts
web/src/labs/marked/parser/Bold.ts
+2
-1
BoldEmphasis.ts
web/src/labs/marked/parser/BoldEmphasis.ts
+2
-1
Emphasis.ts
web/src/labs/marked/parser/Emphasis.ts
+2
-1
Link.ts
web/src/labs/marked/parser/Link.ts
+2
-1
No files found.
web/src/labs/marked/parser/Bold.ts
View file @
7670c953
import
{
marked
}
from
".."
;
import
{
marked
}
from
".."
;
import
Link
from
"./Link"
;
import
Link
from
"./Link"
;
import
PlainText
from
"./PlainText"
;
export
const
BOLD_REG
=
/
\*\*(
.+
?)\*\*
/
;
export
const
BOLD_REG
=
/
\*\*(
.+
?)\*\*
/
;
...
@@ -14,7 +15,7 @@ const renderer = (rawStr: string): string => {
...
@@ -14,7 +15,7 @@ const renderer = (rawStr: string): string => {
return
rawStr
;
return
rawStr
;
}
}
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
[
Link
]);
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
[
Link
,
PlainText
]);
return
`<strong>
${
parsedContent
}
</strong>`
;
return
`<strong>
${
parsedContent
}
</strong>`
;
};
};
...
...
web/src/labs/marked/parser/BoldEmphasis.ts
View file @
7670c953
import
{
marked
}
from
".."
;
import
{
marked
}
from
".."
;
import
Link
from
"./Link"
;
import
Link
from
"./Link"
;
import
PlainText
from
"./PlainText"
;
export
const
BOLD_EMPHASIS_REG
=
/
\*\*\*(
.+
?)\*\*\*
/
;
export
const
BOLD_EMPHASIS_REG
=
/
\*\*\*(
.+
?)\*\*\*
/
;
...
@@ -14,7 +15,7 @@ const renderer = (rawStr: string): string => {
...
@@ -14,7 +15,7 @@ const renderer = (rawStr: string): string => {
return
rawStr
;
return
rawStr
;
}
}
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
[
Link
]);
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
[
Link
,
PlainText
]);
return
`<strong><em>
${
parsedContent
}
</em></strong>`
;
return
`<strong><em>
${
parsedContent
}
</em></strong>`
;
};
};
...
...
web/src/labs/marked/parser/Emphasis.ts
View file @
7670c953
import
{
marked
}
from
".."
;
import
{
marked
}
from
".."
;
import
Link
from
"./Link"
;
import
Link
from
"./Link"
;
import
PlainText
from
"./PlainText"
;
export
const
EMPHASIS_REG
=
/
\*(
.+
?)\*
/
;
export
const
EMPHASIS_REG
=
/
\*(
.+
?)\*
/
;
...
@@ -14,7 +15,7 @@ const renderer = (rawStr: string): string => {
...
@@ -14,7 +15,7 @@ const renderer = (rawStr: string): string => {
return
rawStr
;
return
rawStr
;
}
}
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
[
Link
]);
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
[
Link
,
PlainText
]);
return
`<em>
${
parsedContent
}
</em>`
;
return
`<em>
${
parsedContent
}
</em>`
;
};
};
...
...
web/src/labs/marked/parser/Link.ts
View file @
7670c953
...
@@ -4,6 +4,7 @@ import Bold from "./Bold";
...
@@ -4,6 +4,7 @@ import Bold from "./Bold";
import
{
marked
}
from
".."
;
import
{
marked
}
from
".."
;
import
InlineCode
from
"./InlineCode"
;
import
InlineCode
from
"./InlineCode"
;
import
BoldEmphasis
from
"./BoldEmphasis"
;
import
BoldEmphasis
from
"./BoldEmphasis"
;
import
PlainText
from
"./PlainText"
;
export
const
LINK_REG
=
/
\[(
.*
?)\]\((
.+
?)\)
+/
;
export
const
LINK_REG
=
/
\[(
.*
?)\]\((
.+
?)\)
+/
;
...
@@ -17,7 +18,7 @@ const renderer = (rawStr: string): string => {
...
@@ -17,7 +18,7 @@ const renderer = (rawStr: string): string => {
if
(
!
matchResult
)
{
if
(
!
matchResult
)
{
return
rawStr
;
return
rawStr
;
}
}
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
[
InlineCode
,
BoldEmphasis
,
Emphasis
,
Bold
]);
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
[
InlineCode
,
BoldEmphasis
,
Emphasis
,
Bold
,
PlainText
]);
return
`<a class='link' target='_blank' rel='noreferrer' href='
${
escape
(
matchResult
[
2
])}
'>
${
parsedContent
}
</a>`
;
return
`<a class='link' target='_blank' rel='noreferrer' href='
${
escape
(
matchResult
[
2
])}
'>
${
parsedContent
}
</a>`
;
};
};
...
...
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