suneditor 2.47.1 → 2.47.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/suneditor.min.js +2 -2
- package/package.json +1 -1
- package/src/lib/constructor.js +1 -1
- package/src/lib/core.js +5 -8
- package/src/lib/util.js +3 -2
package/package.json
CHANGED
package/src/lib/constructor.js
CHANGED
|
@@ -416,7 +416,7 @@ export default {
|
|
|
416
416
|
options.plugins = plugins;
|
|
417
417
|
/** Values */
|
|
418
418
|
options.strictMode = options.strictMode !== false;
|
|
419
|
-
options.strictHTMLValidation = options.strictHTMLValidation
|
|
419
|
+
options.strictHTMLValidation = options.strictHTMLValidation !== false;
|
|
420
420
|
options.lang = options.lang || _defaultLang;
|
|
421
421
|
options.value = typeof options.value === 'string' ? options.value : null;
|
|
422
422
|
options.allowedClassNames = new util._w.RegExp((options.allowedClassNames && typeof options.allowedClassNames === 'string' ? options.allowedClassNames + '|' : '') + '^__se__|se-|katex');
|
package/src/lib/core.js
CHANGED
|
@@ -5480,12 +5480,12 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
|
|
|
5480
5480
|
* @returns {String}
|
|
5481
5481
|
*/
|
|
5482
5482
|
cleanHTML: function (html, whitelist, blacklist) {
|
|
5483
|
-
if (!options.strictMode) return html;
|
|
5483
|
+
if (!options.strictMode) return util.htmlCompress(html);
|
|
5484
5484
|
|
|
5485
5485
|
html = this._deleteDisallowedTags(this._parser.parseFromString(util.htmlCompress(html), 'text/html').body.innerHTML).replace(/(<[a-zA-Z0-9\-]+)[^>]*(?=>)/g, this._cleanTags.bind(this, true)).replace(/<br\/?>$/i, '');
|
|
5486
5486
|
const dom = _d.createRange().createContextualFragment(html);
|
|
5487
5487
|
try {
|
|
5488
|
-
util._consistencyCheckOfHTML(dom, this._htmlCheckWhitelistRegExp, this._htmlCheckBlacklistRegExp, this._classNameFilter);
|
|
5488
|
+
util._consistencyCheckOfHTML(dom, this._htmlCheckWhitelistRegExp, this._htmlCheckBlacklistRegExp, this._classNameFilter, options.strictHTMLValidation);
|
|
5489
5489
|
} catch (error) {
|
|
5490
5490
|
console.warn('[SUNEDITOR.cleanHTML.consistencyCheck.fail] ' + error);
|
|
5491
5491
|
}
|
|
@@ -5538,16 +5538,13 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
|
|
|
5538
5538
|
* @returns {String}
|
|
5539
5539
|
*/
|
|
5540
5540
|
convertContentsForEditor: function (contents) {
|
|
5541
|
-
if (!options.strictMode) return contents;
|
|
5541
|
+
if (!options.strictMode) return util.htmlCompress(contents);
|
|
5542
|
+
|
|
5542
5543
|
contents = this._deleteDisallowedTags(this._parser.parseFromString(util.htmlCompress(contents), 'text/html').body.innerHTML).replace(/(<[a-zA-Z0-9\-]+)[^>]*(?=>)/g, this._cleanTags.bind(this, true));
|
|
5543
5544
|
const dom = _d.createRange().createContextualFragment(contents);
|
|
5544
5545
|
|
|
5545
5546
|
try {
|
|
5546
|
-
|
|
5547
|
-
util._consistencyCheckOfHTML(dom, this._htmlCheckWhitelistRegExp, this._htmlCheckBlacklistRegExp, this._classNameFilter);
|
|
5548
|
-
} else {
|
|
5549
|
-
util._consistencyCheckOfHTML(dom, this._htmlCheckWhitelistRegExp, false);
|
|
5550
|
-
}
|
|
5547
|
+
util._consistencyCheckOfHTML(dom, this._htmlCheckWhitelistRegExp, this._htmlCheckBlacklistRegExp, this._classNameFilter, options.strictHTMLValidation);
|
|
5551
5548
|
} catch (error) {
|
|
5552
5549
|
console.warn('[SUNEDITOR.convertContentsForEditor.consistencyCheck.fail] ' + error);
|
|
5553
5550
|
}
|
package/src/lib/util.js
CHANGED
|
@@ -1931,9 +1931,10 @@ const util = {
|
|
|
1931
1931
|
* @param {RegExp} htmlCheckWhitelistRegExp Editor tags whitelist (core._htmlCheckWhitelistRegExp)
|
|
1932
1932
|
* @param {RegExp} htmlCheckBlacklistRegExp Editor tags blacklist (core._htmlCheckBlacklistRegExp)
|
|
1933
1933
|
* @param {Function} classNameFilter Class name filter function
|
|
1934
|
+
* @param {Function} strictHTMLValidation Enforces strict HTML validation based on the editor`s policy
|
|
1934
1935
|
* @private
|
|
1935
1936
|
*/
|
|
1936
|
-
_consistencyCheckOfHTML: function (documentFragment, htmlCheckWhitelistRegExp, htmlCheckBlacklistRegExp, classNameFilter) {
|
|
1937
|
+
_consistencyCheckOfHTML: function (documentFragment, htmlCheckWhitelistRegExp, htmlCheckBlacklistRegExp, classNameFilter, strictHTMLValidation) {
|
|
1937
1938
|
/**
|
|
1938
1939
|
* It is can use ".children(util.getListChildren)" to exclude text nodes, but "documentFragment.children" is not supported in IE.
|
|
1939
1940
|
* So check the node type and exclude the text no (current.nodeType !== 1)
|
|
@@ -1982,7 +1983,7 @@ const util = {
|
|
|
1982
1983
|
else current.removeAttribute('class');
|
|
1983
1984
|
}
|
|
1984
1985
|
|
|
1985
|
-
const result = current.parentNode !== documentFragment && nrtag &&
|
|
1986
|
+
const result = strictHTMLValidation && current.parentNode !== documentFragment && nrtag &&
|
|
1986
1987
|
((this.isListCell(current) && !this.isList(current.parentNode)) ||
|
|
1987
1988
|
((this.isFormatElement(current) || this.isComponent(current)) && !this.isRangeFormatElement(current.parentNode) && !this.getParentElement(current, this.isComponent)));
|
|
1988
1989
|
|