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
64e5c343
Unverified
Commit
64e5c343
authored
Dec 29, 2022
by
boojack
Committed by
GitHub
Dec 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: fix XSS in renderer (#875)
chore: fix xss in renderer
parent
9169b3f2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
7 additions
and
11 deletions
+7
-11
index.ts
web/src/labs/marked/index.ts
+1
-1
Bold.ts
web/src/labs/marked/parser/Bold.ts
+1
-2
BoldEmphasis.ts
web/src/labs/marked/parser/BoldEmphasis.ts
+1
-2
Emphasis.ts
web/src/labs/marked/parser/Emphasis.ts
+1
-2
Link.ts
web/src/labs/marked/parser/Link.ts
+1
-1
Strikethrough.ts
web/src/labs/marked/parser/Strikethrough.ts
+2
-3
No files found.
web/src/labs/marked/index.ts
View file @
64e5c343
...
...
@@ -47,7 +47,7 @@ export const marked = (markdownStr: string, blockParsers = blockElementParserLis
const
matchedLength
=
matchedStr
.
length
;
const
prefixStr
=
markdownStr
.
slice
(
0
,
matchedIndex
);
const
suffixStr
=
markdownStr
.
slice
(
matchedIndex
+
matchedLength
);
return
prefixStr
+
matchedInlineParser
.
renderer
(
matchedStr
)
+
marked
(
suffixStr
,
[],
inlineParsers
);
return
marked
(
prefixStr
,
[],
inlineParsers
)
+
matchedInlineParser
.
renderer
(
matchedStr
)
+
marked
(
suffixStr
,
[],
inlineParsers
);
}
}
...
...
web/src/labs/marked/parser/Bold.ts
View file @
64e5c343
import
{
escape
}
from
"lodash"
;
import
{
marked
}
from
".."
;
import
Link
from
"./Link"
;
...
...
@@ -15,7 +14,7 @@ const renderer = (rawStr: string): string => {
return
rawStr
;
}
const
parsedContent
=
marked
(
escape
(
matchResult
[
1
])
,
[],
[
Link
]);
const
parsedContent
=
marked
(
matchResult
[
1
]
,
[],
[
Link
]);
return
`<strong>
${
parsedContent
}
</strong>`
;
};
...
...
web/src/labs/marked/parser/BoldEmphasis.ts
View file @
64e5c343
import
{
escape
}
from
"lodash"
;
import
{
marked
}
from
".."
;
import
Link
from
"./Link"
;
...
...
@@ -15,7 +14,7 @@ const renderer = (rawStr: string): string => {
return
rawStr
;
}
const
parsedContent
=
marked
(
escape
(
matchResult
[
1
])
,
[],
[
Link
]);
const
parsedContent
=
marked
(
matchResult
[
1
]
,
[],
[
Link
]);
return
`<strong><em>
${
parsedContent
}
</em></strong>`
;
};
...
...
web/src/labs/marked/parser/Emphasis.ts
View file @
64e5c343
import
{
escape
}
from
"lodash"
;
import
{
marked
}
from
".."
;
import
Link
from
"./Link"
;
...
...
@@ -15,7 +14,7 @@ const renderer = (rawStr: string): string => {
return
rawStr
;
}
const
parsedContent
=
marked
(
escape
(
matchResult
[
1
])
,
[],
[
Link
]);
const
parsedContent
=
marked
(
matchResult
[
1
]
,
[],
[
Link
]);
return
`<em>
${
parsedContent
}
</em>`
;
};
...
...
web/src/labs/marked/parser/Link.ts
View file @
64e5c343
...
...
@@ -17,7 +17,7 @@ const renderer = (rawStr: string): string => {
if
(
!
matchResult
)
{
return
rawStr
;
}
const
parsedContent
=
marked
(
escape
(
matchResult
[
1
])
,
[],
[
InlineCode
,
BoldEmphasis
,
Emphasis
,
Bold
]);
const
parsedContent
=
marked
(
matchResult
[
1
]
,
[],
[
InlineCode
,
BoldEmphasis
,
Emphasis
,
Bold
]);
return
`<a class='link' target='_blank' rel='noreferrer' href='
${
escape
(
matchResult
[
2
])}
'>
${
parsedContent
}
</a>`
;
};
...
...
web/src/labs/marked/parser/Strikethrough.ts
View file @
64e5c343
import
{
marked
}
from
"..
"
;
import
{
escape
}
from
"lodash
"
;
export
const
STRIKETHROUGH_REG
=
/~~
(
.+
?)
~~/
;
...
...
@@ -13,8 +13,7 @@ const renderer = (rawStr: string): string => {
return
rawStr
;
}
const
parsedContent
=
marked
(
matchResult
[
1
],
[],
[]);
return
`<del>
${
parsedContent
}
</del>`
;
return
`<del>
${
escape
(
matchResult
[
1
])}
</del>`
;
};
export
default
{
...
...
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