diff --git a/core/modules/editor/engines/framed.js b/core/modules/editor/engines/framed.js index 12c48bcb5..3a5adea75 100644 --- a/core/modules/editor/engines/framed.js +++ b/core/modules/editor/engines/framed.js @@ -48,7 +48,7 @@ function FramedEngine(options) { this.iframeDoc.body.style.padding = "0"; this.widget.domNodes.push(this.iframeNode); // Construct the textarea or input node - var tag = $tw.utils.isTagNameSafe(this.widget.editTag, "input"); + var tag = $tw.utils.makeTagNameSafe(this.widget.editTag, "input"); // if($tw.config.htmlUnsafeElements.indexOf(tag) !== -1) { // tag = "input"; // } diff --git a/core/modules/editor/engines/simple.js b/core/modules/editor/engines/simple.js index 20aa1afac..fbd02399b 100644 --- a/core/modules/editor/engines/simple.js +++ b/core/modules/editor/engines/simple.js @@ -22,7 +22,7 @@ function SimpleEngine(options) { this.parentNode = options.parentNode; this.nextSibling = options.nextSibling; // Construct the textarea or input node - var tag = $tw.utils.isTagNameSafe(this.widget.editTag,"input"); + var tag = $tw.utils.makeTagNameSafe(this.widget.editTag,"input"); // var tag = this.widget.editTag; // if($tw.config.htmlUnsafeElements.indexOf(tag) !== -1) { // tag = "input"; diff --git a/core/modules/utils/dom/dom.js b/core/modules/utils/dom/dom.js index c066cca8b..5e936e0b6 100644 --- a/core/modules/utils/dom/dom.js +++ b/core/modules/utils/dom/dom.js @@ -389,10 +389,10 @@ exports.querySelectorAllSafe = function(selector,baseElement) { /* Make sure HTML tag names are valid */ -exports.isTagNameSafe = function(tag,defaultTag) { +exports.makeTagNameSafe = function(tag,defaultTag) { defaultTag = defaultTag || "SPAN"; - // This implements standard DOM elements: https://html.spec.whatwg.org/#syntax-tag-name - // It does _not_ implement Custom Elements: https://html.spec.whatwg.org/#valid-custom-element-name + // This implements a check for standard DOM elements: https://html.spec.whatwg.org/#syntax-tag-name + // It does _not_ deal with Custom Elements: https://html.spec.whatwg.org/#valid-custom-element-name var regexp = /[a-zA-Z0-9]/g; if(tag && tag.match(regexp) && $tw.config.htmlUnsafeElements.indexOf(tag) === -1) { return tag; diff --git a/core/modules/widgets/button.js b/core/modules/widgets/button.js index 3fd7a90e2..712c15c26 100644 --- a/core/modules/widgets/button.js +++ b/core/modules/widgets/button.js @@ -41,7 +41,7 @@ ButtonWidget.prototype.render = function(parent,nextSibling) { // if(this.buttonTag && $tw.config.htmlUnsafeElements.indexOf(this.buttonTag) === -1) { // tag = this.buttonTag; // } - tag = $tw.utils.isTagNameSafe(this.buttonTag,tag) + tag = $tw.utils.makeTagNameSafe(this.buttonTag,tag) domNode = this.document.createElement(tag); this.domNode = domNode; // Assign classes diff --git a/core/modules/widgets/draggable.js b/core/modules/widgets/draggable.js index bcbc7bc11..628c2cbff 100644 --- a/core/modules/widgets/draggable.js +++ b/core/modules/widgets/draggable.js @@ -38,7 +38,7 @@ DraggableWidget.prototype.render = function(parent,nextSibling) { // Execute our logic this.execute(); // Sanitise the specified tag - tag = $tw.utils.isTagNameSafe(this.draggableTag,"div"); + tag = $tw.utils.makeTagNameSafe(this.draggableTag,"div"); // if($tw.config.htmlUnsafeElements.indexOf(tag) !== -1) { // tag = "div"; // } diff --git a/core/modules/widgets/droppable.js b/core/modules/widgets/droppable.js index d09a28d37..e9ede0e50 100644 --- a/core/modules/widgets/droppable.js +++ b/core/modules/widgets/droppable.js @@ -35,7 +35,7 @@ DroppableWidget.prototype.render = function(parent,nextSibling) { // Compute attributes and execute state this.computeAttributes(); this.execute(); - tag = $tw.utils.isTagNameSafe(this.droppableTag,tag); + tag = $tw.utils.makeTagNameSafe(this.droppableTag,tag); // if(this.droppableTag && $tw.config.htmlUnsafeElements.indexOf(this.droppableTag) === -1) { // tag = this.droppableTag; // } diff --git a/core/modules/widgets/element.js b/core/modules/widgets/element.js index 76efae075..4b46e52d0 100755 --- a/core/modules/widgets/element.js +++ b/core/modules/widgets/element.js @@ -31,7 +31,7 @@ ElementWidget.prototype.render = function(parent,nextSibling) { this.computeAttributes(); // Neuter blacklisted elements this.tag = this.parseTreeNode.tag; - this.tag = $tw.utils.isTagNameSafe(this.tag, "safe" + this.tag); + this.tag = $tw.utils.makeTagNameSafe(this.tag, "safe" + this.tag); // if($tw.config.htmlUnsafeElements.indexOf(this.tag) !== -1) { // this.tag = "safe-" + this.tag; // } diff --git a/core/modules/widgets/eventcatcher.js b/core/modules/widgets/eventcatcher.js index 3ada1a6e4..6de3d9690 100644 --- a/core/modules/widgets/eventcatcher.js +++ b/core/modules/widgets/eventcatcher.js @@ -35,7 +35,7 @@ EventWidget.prototype.render = function(parent,nextSibling) { this.execute(); // Create element var tag = this.parseTreeNode.isBlock ? "div" : "span"; - tag = $tw.utils.isTagNameSafe(this.elementTag,tag) + tag = $tw.utils.makeTagNameSafe(this.elementTag,tag) // if(this.elementTag && $tw.config.htmlUnsafeElements.indexOf(this.elementTag) === -1) { // tag = this.elementTag; // } diff --git a/core/modules/widgets/keyboard.js b/core/modules/widgets/keyboard.js index ca75fcaf5..e6fd97694 100644 --- a/core/modules/widgets/keyboard.js +++ b/core/modules/widgets/keyboard.js @@ -34,7 +34,7 @@ KeyboardWidget.prototype.render = function(parent,nextSibling) { this.computeAttributes(); this.execute(); var tag = this.parseTreeNode.isBlock ? "div" : "span"; - tag = $tw.utils.isTagNameSafe(this.tag,tag); + tag = $tw.utils.makeTagNameSafe(this.tag,tag); // if(this.tag && $tw.config.htmlUnsafeElements.indexOf(this.tag) === -1) { // tag = this.tag; // } diff --git a/core/modules/widgets/link.js b/core/modules/widgets/link.js index 411e9de6b..b6e0da156 100755 --- a/core/modules/widgets/link.js +++ b/core/modules/widgets/link.js @@ -61,7 +61,7 @@ LinkWidget.prototype.renderLink = function(parent,nextSibling) { var self = this; // Sanitise the specified tag var tag = this.linkTag; - tag = $tw.utils.isTagNameSafe(tag,"a"); + tag = $tw.utils.makeTagNameSafe(tag,"a"); // if($tw.config.htmlUnsafeElements.indexOf(tag) !== -1) { // tag = "a"; // } diff --git a/core/modules/widgets/reveal.js b/core/modules/widgets/reveal.js index 9515683dd..3acc01841 100755 --- a/core/modules/widgets/reveal.js +++ b/core/modules/widgets/reveal.js @@ -33,7 +33,7 @@ RevealWidget.prototype.render = function(parent,nextSibling) { this.computeAttributes(); this.execute(); var tag = this.parseTreeNode.isBlock ? "div" : "span"; - tag = $tw.utils.isTagNameSafe(this.revealTag,tag); + tag = $tw.utils.makeTagNameSafe(this.revealTag,tag); // if(this.revealTag && $tw.config.htmlUnsafeElements.indexOf(this.revealTag) === -1) { // tag = this.revealTag; // }