Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Sunny_yiyi
Swagger Ui
提交
f5b84e59
S
Swagger Ui
项目概览
Sunny_yiyi
/
Swagger Ui
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Swagger Ui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
f5b84e59
编写于
3月 31, 2021
作者:
T
Tim Lai
提交者:
GitHub
3月 31, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: markdown sanitization of form tag (#7146)
上级
4abbc62b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
1 deletion
+13
-1
src/core/components/providers/markdown.jsx
src/core/components/providers/markdown.jsx
+1
-1
test/unit/xss/markdown-script-sanitization.jsx
test/unit/xss/markdown-script-sanitization.jsx
+12
-0
未找到文件。
src/core/components/providers/markdown.jsx
浏览文件 @
f5b84e59
...
@@ -68,7 +68,7 @@ export function sanitizer(str, { useUnsafeMarkdown = false } = {}) {
...
@@ -68,7 +68,7 @@ export function sanitizer(str, { useUnsafeMarkdown = false } = {}) {
return
DomPurify
.
sanitize
(
str
,
{
return
DomPurify
.
sanitize
(
str
,
{
ADD_ATTR
:
[
"
target
"
],
ADD_ATTR
:
[
"
target
"
],
FORBID_TAGS
:
[
"
style
"
],
FORBID_TAGS
:
[
"
style
"
,
"
form
"
],
ALLOW_DATA_ATTR
,
ALLOW_DATA_ATTR
,
FORBID_ATTR
,
FORBID_ATTR
,
})
})
...
...
test/unit/xss/markdown-script-sanitization.jsx
浏览文件 @
f5b84e59
...
@@ -16,6 +16,12 @@ describe("Markdown Script Sanitization", function() {
...
@@ -16,6 +16,12 @@ describe("Markdown Script Sanitization", function() {
const
el
=
render
(<
Markdown
source
=
{
str
}
/>)
const
el
=
render
(<
Markdown
source
=
{
str
}
/>)
expect
(
el
.
html
()).
toEqual
(
`<div class="markdown"><p><img src="x"></p>\n</div>`
)
expect
(
el
.
html
()).
toEqual
(
`<div class="markdown"><p><img src="x"></p>\n</div>`
)
})
})
it
(
"
sanitizes <form> elements
"
,
function
()
{
const
str
=
`"<form action='https://do.not.use.url/fake' method='post' action='java'><input type='email' id='email' placeholder='Email-address' name='email' value=''><button type='submit'>Login</button>"`
const
el
=
render
(<
Markdown
source
=
{
str
}
/>)
expect
(
el
.
html
()).
toEqual
(
`<div class="markdown"><p>"</p><input value name="email" placeholder="Email-address" id="email" type="email"><button type="submit">Login</button>"<p></p>\n</div>`
)
})
})
})
describe
(
"
OAS 3
"
,
function
()
{
describe
(
"
OAS 3
"
,
function
()
{
...
@@ -30,5 +36,11 @@ describe("Markdown Script Sanitization", function() {
...
@@ -30,5 +36,11 @@ describe("Markdown Script Sanitization", function() {
const
el
=
render
(<
OAS3Markdown
source
=
{
str
}
/>)
const
el
=
render
(<
OAS3Markdown
source
=
{
str
}
/>)
expect
(
el
.
html
()).
toEqual
(
`<div class="renderedMarkdown"><p><img src="x"></p></div>`
)
expect
(
el
.
html
()).
toEqual
(
`<div class="renderedMarkdown"><p><img src="x"></p></div>`
)
})
})
it
(
"
sanitizes <form> elements
"
,
function
()
{
const
str
=
`"<form action='https://do.not.use.url/fake' method='post' action='java'><input type='email' id='email' placeholder='Email-address' name='email' value=''><button type='submit'>Login</button>"`
const
el
=
render
(<
OAS3Markdown
source
=
{
str
}
/>)
expect
(
el
.
html
()).
toEqual
(
`<div class="renderedMarkdown"><p>"</p><input value name="email" placeholder="Email-address" id="email" type="email"><button type="submit">Login</button>"<p></p></div>`
)
})
})
})
})
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录