Skip to content

Commit

Permalink
sanitize improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
khaydarov committed Apr 22, 2017
1 parent bff230e commit 49a4290
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 14 deletions.
4 changes: 2 additions & 2 deletions codex-editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion codex-editor.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions modules/callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @description Module works with editor added Elements
*
* @author Codex Team
* @version 1.3.12
* @version 1.4.0
*/

module.exports = (function (callbacks) {
Expand Down Expand Up @@ -933,7 +933,6 @@ module.exports = (function (callbacks) {

/** Temporary DIV that is used to work with childs as arrays item */
var div = editor.draw.node('DIV', '', {}),
cleaner = new editor.sanitizer.init(),
cleanData,
fragment;

Expand All @@ -942,7 +941,8 @@ module.exports = (function (callbacks) {

if ( htmlData.trim() != '' ) {

cleanData = cleaner.clean(htmlData);
console.log('here');
cleanData = editor.sanitizer.clean(htmlData);
div.innerHTML = cleanData;

} else {
Expand Down
20 changes: 18 additions & 2 deletions modules/sanitizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,30 @@ module.exports = (function (sanitizer) {

sanitizer.Config = Config;

sanitizer.init = function () {
let init_ = function (userCustomConfig) {

let configuration = Config.CUSTOM || Config.BASIC;
let configuration = userCustomConfig || Config.CUSTOM || Config.BASIC;
console.log(configuration);

return new janitor(configuration);

};

/**
* Cleans string from unwanted tags
* @protected
* @param {String} dirtyString - taint string
* @param {Object} customConfig - allowed tags
*/
sanitizer.clean = function(dirtyString, customConfig) {

console.log('her');
let janitorInstance = init_(customConfig);

return janitorInstance.clean(dirtyString);

};

return sanitizer;

})({});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codex.editor",
"version": "1.6.2",
"version": "1.6.3",
"description": "Codex Editor. Native JS, based on API and Open Source",
"main": "index.js",
"scripts": {
Expand Down
3 changes: 1 addition & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ var ExtractTextWebpackPlugin = require('extract-text-webpack-plugin');
module.exports = {

entry: {
"whatwg-fetch": "whatwg-fetch",
"codex-editor": "./codex"
},
output: {
Expand All @@ -37,7 +36,7 @@ module.exports = {
watch: true,

watchOptions: {
aggregateTimeOut: 100
aggregateTimeOut: 50
},

devtool: NODE_ENV == 'development' ? "source-map" : null,
Expand Down
2 changes: 0 additions & 2 deletions whatwg-fetch.js

This file was deleted.

1 change: 0 additions & 1 deletion whatwg-fetch.js.map

This file was deleted.

0 comments on commit 49a4290

Please sign in to comment.