Skip to content

Commit ef01a64

Browse files
committed
ADD: DOMPurify for preventing xss attacks
1 parent 65d78cb commit ef01a64

20 files changed

+2695
-951
lines changed

.bowerrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

Gruntfile.coffee

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,18 @@ module.exports = (grunt) ->
8888
objectToExport: 'Simditor'
8989
globalAlias: 'Simditor'
9090
deps:
91-
'default': ['$', 'SimpleModule', 'simpleHotkeys', 'simpleUploader']
92-
amd: ['jquery', 'simple-module', 'simple-hotkeys', 'simple-uploader']
93-
cjs: ['jquery', 'simple-module', 'simple-hotkeys', 'simple-uploader']
91+
'default': ['$', 'SimpleModule', 'simpleHotkeys', 'simpleUploader', 'DOMPurify']
92+
amd: ['jquery', 'simple-module', 'simple-hotkeys', 'simple-uploader', 'dompurify']
93+
cjs: ['jquery', 'simple-module', 'simple-hotkeys', 'simple-uploader', 'dompurify']
9494
global:
95-
items: ['jQuery', 'SimpleModule', 'simple.hotkeys', 'simple.uploader']
95+
items: ['jQuery', 'SimpleModule', 'simple.hotkeys', 'simple.uploader', 'window.DOMPurify']
9696
prefix: ''
9797
suffix: ''
9898

9999
copy:
100100
vendor:
101101
files: [{
102-
src: 'vendor/bower/jquery/dist/jquery.min.js',
102+
src: 'node_modules/jquery/dist/jquery.min.js',
103103
dest: 'site/assets/scripts/jquery.min.js'
104104
}]
105105
styles:
@@ -109,14 +109,17 @@ module.exports = (grunt) ->
109109
}]
110110
scripts:
111111
files: [{
112-
src: 'vendor/bower/simple-module/lib/module.js',
112+
src: 'node_modules/simple-module/lib/module.js',
113113
dest: 'site/assets/scripts/module.js'
114114
}, {
115-
src: 'vendor/bower/simple-uploader/lib/uploader.js',
115+
src: 'node_modules/simple-uploader/lib/uploader.js',
116116
dest: 'site/assets/scripts/uploader.js'
117117
}, {
118-
src: 'vendor/bower/simple-hotkeys/lib/hotkeys.js',
118+
src: 'node_modules/simple-hotkeys/lib/hotkeys.js',
119119
dest: 'site/assets/scripts/hotkeys.js'
120+
}, {
121+
src: 'node_modules/dompurify/dist/purify.js',
122+
dest: 'site/assets/scripts/dompurify.js'
120123
}, {
121124
src: 'lib/simditor.js',
122125
dest: 'site/assets/scripts/simditor.js'
@@ -129,17 +132,20 @@ module.exports = (grunt) ->
129132
src: 'lib/*',
130133
dest: 'package/scripts/'
131134
}, {
132-
src: 'vendor/bower/jquery/dist/jquery.min.js',
135+
src: 'node_modules/jquery/dist/jquery.min.js',
133136
dest: 'package/scripts/jquery.min.js'
134137
}, {
135-
src: 'vendor/bower/simple-module/lib/module.js',
138+
src: 'node_modules/simple-module/lib/module.js',
136139
dest: 'package/scripts/module.js'
137140
}, {
138-
src: 'vendor/bower/simple-uploader/lib/uploader.js',
141+
src: 'node_modules/simple-uploader/lib/uploader.js',
139142
dest: 'package/scripts/uploader.js'
140143
}, {
141-
src: 'vendor/bower/simple-hotkeys/lib/hotkeys.js',
144+
src: 'node_modules/simple-hotkeys/lib/hotkeys.js',
142145
dest: 'package/scripts/hotkeys.js'
146+
}, {
147+
src: 'node_modules/dompurify/dist/purify.js',
148+
dest: 'package/scripts/dompurify.js'
143149
}, {
144150
expand: true,
145151
flatten: true
@@ -234,10 +240,11 @@ module.exports = (grunt) ->
234240
'spec/buttons/*.js'
235241
]
236242
vendor: [
237-
'vendor/bower/jquery/dist/jquery.min.js'
238-
'vendor/bower/simple-module/lib/module.js'
239-
'vendor/bower/simple-uploader/lib/uploader.js'
240-
'vendor/bower/simple-hotkeys/lib/hotkeys.js'
243+
'node_modules/jquery/dist/jquery.min.js'
244+
'node_modules/simple-module/lib/module.js'
245+
'node_modules/simple-uploader/lib/uploader.js'
246+
'node_modules/simple-hotkeys/lib/hotkeys.js'
247+
'node_modules/dompurify/dist/purify.js'
241248
]
242249

243250
curl:

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ It is used by [Tower](http://tower.im) -- a popular project management web appli
99
Supported Browsers: IE10+、Chrome、Firefox、Safari.
1010
* [Download Zip](https://github.com/mycolorway/simditor/releases)
1111
* Install with npm: $ npm install simditor</li>
12-
* Install with bower: $ bower install simditor</li>
1312

1413
Demo and docs can be found [here](http://simditor.tower.im/).

bower.json

Lines changed: 0 additions & 40 deletions
This file was deleted.

circle.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

lib/simditor.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
/*!
22
* Simditor v2.3.21
33
* http://simditor.tower.im/
4-
* 2018-10-17
4+
* 2018-11-09
55
*/
66
(function (root, factory) {
77
if (typeof define === 'function' && define.amd) {
88
// AMD. Register as an anonymous module unless amdModuleId is set
9-
define('simditor', ["jquery","simple-module","simple-hotkeys","simple-uploader"], function ($, SimpleModule, simpleHotkeys, simpleUploader) {
10-
return (root['Simditor'] = factory($, SimpleModule, simpleHotkeys, simpleUploader));
9+
define('simditor', ["jquery","simple-module","simple-hotkeys","simple-uploader","dompurify"], function ($, SimpleModule, simpleHotkeys, simpleUploader, DOMPurify) {
10+
return (root['Simditor'] = factory($, SimpleModule, simpleHotkeys, simpleUploader, DOMPurify));
1111
});
1212
} else if (typeof exports === 'object') {
1313
// Node. Does not work with strict CommonJS, but
1414
// only CommonJS-like environments that support module.exports,
1515
// like Node.
16-
module.exports = factory(require("jquery"),require("simple-module"),require("simple-hotkeys"),require("simple-uploader"));
16+
module.exports = factory(require("jquery"),require("simple-module"),require("simple-hotkeys"),require("simple-uploader"),require("dompurify"));
1717
} else {
18-
root['Simditor'] = factory(jQuery,SimpleModule,simple.hotkeys,simple.uploader);
18+
root['Simditor'] = factory(jQuery,SimpleModule,simple.hotkeys,simple.uploader,window.DOMPurify);
1919
}
20-
}(this, function ($, SimpleModule, simpleHotkeys, simpleUploader) {
20+
}(this, function ($, SimpleModule, simpleHotkeys, simpleUploader, DOMPurify) {
2121

2222
var AlignmentButton, BlockquoteButton, BoldButton, Button, Clipboard, CodeButton, CodePopover, ColorButton, FontScaleButton, Formatter, HrButton, ImageButton, ImagePopover, IndentButton, Indentation, InputManager, ItalicButton, Keystroke, LinkButton, LinkPopover, ListButton, OrderListButton, OutdentButton, Popover, Selection, Simditor, StrikethroughButton, TableButton, TitleButton, Toolbar, UnderlineButton, UndoManager, UnorderListButton, Util,
2323
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
@@ -2342,7 +2342,7 @@ Clipboard = (function(superClass) {
23422342
return function() {
23432343
var pasteContent;
23442344
_this.editor.hidePopover();
2345-
_this.editor.body.get(0).innerHTML = state.html;
2345+
_this.editor.body.get(0).innerHTML = DOMPurify ? DOMPurify.sanitize(state.html) : state.html;
23462346
_this.editor.undoManager.caretPosition(state.caret);
23472347
_this.editor.body.focus();
23482348
_this.editor.selection.reset();
@@ -2649,7 +2649,7 @@ Simditor = (function(superClass) {
26492649
Simditor.prototype.setValue = function(val) {
26502650
this.hidePopover();
26512651
this.textarea.val(val);
2652-
this.body.get(0).innerHTML = val;
2652+
this.body.get(0).innerHTML = DOMPurify ? DOMPurify.sanitize(val) : val;
26532653
this.formatter.format();
26542654
this.formatter.decorate();
26552655
this.util.reflow(this.body);

0 commit comments

Comments
 (0)