Skip to content

Commit

Permalink
修复ice富文本编辑器中插入图片URL链接的XSS漏洞
Browse files Browse the repository at this point in the history
  • Loading branch information
zmister committed Oct 20, 2021
1 parent 5034ca7 commit 46ef532
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion static/mrdoc/mrdoc.editor.js
Expand Up @@ -393,7 +393,8 @@ insertImg = function(e){
// 按钮点击插入输入框图片链接
insertImgUrl = function(){
if(editor_mode == 3){
editor.addValue('<img src="' + $("#img_url_input").val() + '" />')
img_str = DOMPurify.sanitize('<img src="' + $("#img_url_input").val() + '" />',{ADD_TAGS: ['iframe']})
editor.addValue(img_str)
}else{
editor.insertValue("\n![](" + $("#img_url_input").val() + ")");
editor.focus()
Expand Down
1 change: 1 addition & 0 deletions template/app_doc/editor/create_base.html
Expand Up @@ -234,6 +234,7 @@
{% elif editor_mode == 3 %}
<!-- iceEditor富文本编辑器 -->
<script src="{% static 'iceEditor/src/iceEditor.min.js' %}?version={{mrdoc_version}}"></script>
<script src="{% static 'editor.md/lib/purify.min.js' %}?version={{mrdoc_version}}"></script>
{% include 'app_doc/editor/tpl_editor_ice.html' %}
{% elif editor_mode == 4 %}
<!-- 在线表格 -->
Expand Down
2 changes: 1 addition & 1 deletion template/app_doc/editor/create_doc.html
Expand Up @@ -272,7 +272,7 @@
var content = editor.getHTML()
var pre_content = editor.getValue()
}else if(editor_mode == 3){
var content = editor.getHTML()
var content = DOMPurify.sanitize(editor.getHTML(),{ADD_TAGS: ['iframe']})
var pre_content = editor.getText()
}else if(editor_mode == 4){
var content = '';
Expand Down
2 changes: 1 addition & 1 deletion template/app_doc/editor/modify_doc.html
Expand Up @@ -249,7 +249,7 @@
var content = editor.getHTML()
var pre_content = editor.getValue()
}else if(editor_mode == 3){
var content = editor.getHTML()
var content = DOMPurify.sanitize(editor.getHTML(),{ADD_TAGS: ['iframe']})
var pre_content = editor.getText()
}else if(editor_mode == 4){
var content = '';
Expand Down

0 comments on commit 46ef532

Please sign in to comment.