diff --git a/core/modules/filter/filter.filter_html.admin.js b/core/modules/filter/filter.filter_html.admin.js index 3931c5959695..8c9cef64f3a2 100644 --- a/core/modules/filter/filter.filter_html.admin.js +++ b/core/modules/filter/filter.filter_html.admin.js @@ -98,9 +98,6 @@ that.$allowedHTMLFormItem.on('change.updateUserTags', function () { that.userTags = _.difference(that._parseSetting(this.value), that.autoTags); }); - }).on('keyup', function (e) { - if (e.keyCode != 13) return; - $(this).val($(this).val().replace(/\n/g, "")); }); }, @@ -241,38 +238,36 @@ var allowedTags = setting.match(/(<[^>]+>)/g); var sandbox = document.createElement('div'); var rules = {}; - if (allowedTags) { - for (var t = 0; t < allowedTags.length; t++) { - // Let the browser do the parsing work for us. - sandbox.innerHTML = allowedTags[t]; - node = sandbox.firstChild; - tag = (node !== null) ? node.tagName.toLowerCase() : null; + for (var t = 0; t < allowedTags.length; t++) { + // Let the browser do the parsing work for us. + sandbox.innerHTML = allowedTags[t]; + node = sandbox.firstChild; + tag = node.tagName.toLowerCase(); - // Build the Drupal.FilterHtmlRule object. - rule = new Drupal.FilterHTMLRule(); - // We create one rule per allowed tag, so always one tag. - rule.restrictedTags.tags = [tag]; - // Add the attribute restrictions. - attributes = (node !== null) ? node.attributes : ''; - for (var i = 0; i < attributes.length; i++) { - attribute = attributes.item(i); - var attributeName = attribute.nodeName; - // @todo Drupal.FilterHtmlRule does not allow for generic attribute - // value restrictions, only for the "class" and "style" attribute's - // values. The filter_html filter always disallows the "style" - // attribute, so we only need to support "class" attribute value - // restrictions. Fix once https://www.drupal.org/node/2567801 lands. - if (attributeName === 'class') { - var attributeValue = attribute.textContent; - rule.restrictedTags.allowed.classes = attributeValue.split(' '); - } - else { - rule.restrictedTags.allowed.attributes.push(attributeName); - } + // Build the Drupal.FilterHtmlRule object. + rule = new Drupal.FilterHTMLRule(); + // We create one rule per allowed tag, so always one tag. + rule.restrictedTags.tags = [tag]; + // Add the attribute restrictions. + attributes = node.attributes; + for (var i = 0; i < attributes.length; i++) { + attribute = attributes.item(i); + var attributeName = attribute.nodeName; + // @todo Drupal.FilterHtmlRule does not allow for generic attribute + // value restrictions, only for the "class" and "style" attribute's + // values. The filter_html filter always disallows the "style" + // attribute, so we only need to support "class" attribute value + // restrictions. Fix once https://www.drupal.org/node/2567801 lands. + if (attributeName === 'class') { + var attributeValue = attribute.textContent; + rule.restrictedTags.allowed.classes = attributeValue.split(' '); + } + else { + rule.restrictedTags.allowed.attributes.push(attributeName); } - - rules[tag] = rule; } + + rules[tag] = rule; } return rules; }, diff --git a/core/modules/filter/src/Plugin/Filter/FilterHtml.php b/core/modules/filter/src/Plugin/Filter/FilterHtml.php index e89e40547a24..63985ffdd28e 100644 --- a/core/modules/filter/src/Plugin/Filter/FilterHtml.php +++ b/core/modules/filter/src/Plugin/Filter/FilterHtml.php @@ -46,10 +46,12 @@ class FilterHtml extends FilterBase { */ public function settingsForm(array $form, FormStateInterface $form_state) { $form['allowed_html'] = array( - '#type' => 'textarea', + '#type' => 'textfield', '#title' => $this->t('Allowed HTML tags'), '#default_value' => $this->settings['allowed_html'], + '#maxlength' => 2048, '#description' => $this->t('A list of HTML tags that can be used. By default only the lang and dir attributes are allowed for all HTML tags. Each HTML tag may have attributes which are treated as allowed attribute names for that HTML tag. Each attribute may allow all values, or only allow specific values. Attribute names or values may be written as a prefix and wildcard like jump-*. JavaScript event attributes, JavaScript URLs, and CSS are always stripped.'), + '#size' => 250, '#attached' => array( 'library' => array( 'filter/drupal.filter.filter_html.admin',