From 257ff67a51898cd9e8322f03daabeb8bd1a31e1e Mon Sep 17 00:00:00 2001 From: Alan Date: Fri, 24 Sep 2021 10:31:14 +0800 Subject: [PATCH] sync --- docs/src/Roo_HtmlEditorCore.js.html | 203 ++-------------------------- 1 file changed, 8 insertions(+), 195 deletions(-) diff --git a/docs/src/Roo_HtmlEditorCore.js.html b/docs/src/Roo_HtmlEditorCore.js.html index a7d8d1a16c..f248a88777 100644 --- a/docs/src/Roo_HtmlEditorCore.js.html +++ b/docs/src/Roo_HtmlEditorCore.js.html @@ -991,7 +991,7 @@ // cleans up the whole document.. Roo.log('cleanuppaste'); - this.cleanUpChildren(this.doc.body); + this.cleanUpChild(this.doc.body); var clean = this.cleanWordChars(this.doc.body.innerHTML); if (clean != this.doc.body.innerHTML) { this.doc.body.innerHTML = clean; @@ -1013,191 +1013,16 @@ }, - cleanUpChildren : function (n) - { - if (!n.childNodes.length) { - return; - } - for (var i = n.childNodes.length-1; i > -1 ; i--) { - this.cleanUpChild(n.childNodes[i]); - } - }, - cleanUpChild : function (node) { - var ed = this; - //console.log(node); - if (node.nodeName == "#text") { - // clean up silly Windows -- stuff? - return; - } - if (node.nodeName == "#comment") { - if (!this.allowComments) { - node.parentNode.removeChild(node); - } - // clean up silly Windows -- stuff? - return; - } - var lcname = node.tagName.toLowerCase(); - // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full - // whitelist of tags.. - - if (this.black.indexOf(lcname) > -1 && this.clearUp ) { - // remove node. - node.parentNode.removeChild(node); - return; - - } - - var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1; - - // spans with no attributes - just remove them.. - if ((!node.attributes || !node.attributes.length) && lcname == 'span') { - remove_keep_children = true; - } - - // remove <a name=....> as rendering on yahoo mailer is borked with this. - // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer.. - - //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) { - // remove_keep_children = true; - //} - - if (remove_keep_children) { - this.cleanUpChildren(node); - // inserts everything just before this node... - while (node.childNodes.length) { - var cn = node.childNodes[0]; - node.removeChild(cn); - node.parentNode.insertBefore(cn, node); - } - node.parentNode.removeChild(node); - return; - } - if (!node.attributes || !node.attributes.length) { - - - - - this.cleanUpChildren(node); - return; - } - - function cleanAttr(n,v) - { - - if (v.match(/^\./) || v.match(/^\//)) { - return; - } - if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) { - return; - } - if (v.match(/^#/)) { - return; - } - if (v.match(/^\{/)) { // allow template editing. - return; - } -// Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v); - node.removeAttribute(n); - - } - - var cwhite = this.cwhite; - var cblack = this.cblack; - - function cleanStyle(n,v) - { - if (v.match(/expression/)) { //XSS?? should we even bother.. - node.removeAttribute(n); - return; - } - - var parts = v.split(/;/); - var clean = []; - - Roo.each(parts, function(p) { - p = p.replace(/^\s+/g,'').replace(/\s+$/g,''); - if (!p.length) { - return true; - } - var l = p.split(':').shift().replace(/\s+/g,''); - l = l.replace(/^\s+/g,'').replace(/\s+$/g,''); - - if ( cwhite.length && cblack.indexOf(l) > -1) { -// Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v); - //node.removeAttribute(n); - return true; - } - //Roo.log() - // only allow 'c whitelisted system attributes' - if ( cwhite.length && cwhite.indexOf(l) < 0 && cwhite.indexOf(l.toLowerCase()) < 0 ) { -// Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v); - //node.removeAttribute(n); - return true; - } - - - - - clean.push(p); - return true; - }); - if (clean.length) { - node.setAttribute(n, clean.join(';')); - } else { - node.removeAttribute(n); - } - - } - - - for (var i = node.attributes.length-1; i > -1 ; i--) { - var a = node.attributes[i]; - //console.log(a); - - if (a.name.toLowerCase().substr(0,2)=='on') { - node.removeAttribute(a.name); - continue; - } - if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) { - node.removeAttribute(a.name); - continue; - } - if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) { - cleanAttr(a.name,a.value); // fixme.. - continue; - } - if (a.name == 'style') { - cleanStyle(a.name,a.value); - continue; - } - /// clean up MS crap.. - // tecnically this should be a list of valid class'es.. - - - if (a.name == 'class') { - if (a.value.match(/^Mso/)) { - node.removeAttribute('class'); - } - - if (a.value.match(/^body$/)) { - node.removeAttribute('class'); - } - continue; - } - - // style cleanup!? - // class cleanup? - - } - - - this.cleanUpChildren(node); + Roo.htmleditor.FilterComment.walk(node); + Roo.htmleditor.FilterAttributes.walkWith(node, this.ablack, this.aclean, this.cwhite, this.cblack ) + Roo.htmleditor.FilterBlack.walkWith(node,this.black); + Roo.htmleditor.FilterKeepChildren.walkWith(node,this.remove); }, @@ -1208,14 +1033,7 @@ */ cleanWord : function(node) { - if (!node) { - Roo.htmleditor.FilterWord.walk(this.doc.body); - return; - } - Roo.htmleditor.FilterWord.walk(node); - return; - - + Roo.htmleditor.FilterWord.walk(node ? node : this.doc.body); }, @@ -1226,19 +1044,14 @@ */ cleanTableWidths : function(node) { + Roo.htmleditor.FilterTable.walk(node ? node : this.doc.body); - if (!node) { - Roo.htmleditor.FilterTable.walk(this.doc.body); - return; - } - Roo.htmleditor.FilterTable.walk(node); - }, - + /* ?? why ?? */ domToHTML : function(currentElement, depth, nopadtext) { depth = depth || 0; -- 2.39.2