diff --git a/core/modules/filter/config/schema/filter.schema.yml b/core/modules/filter/config/schema/filter.schema.yml index 6756f1e..74f2d35 100644 --- a/core/modules/filter/config/schema/filter.schema.yml +++ b/core/modules/filter/config/schema/filter.schema.yml @@ -52,13 +52,13 @@ filter_settings.filter_html: mapping: allowed_html: type: sequence - label: 'Allowed HTML' + label: 'Allowed HTML tags' sequence: type: sequence - label: 'Attributes' + label: 'Allowed attributes' sequence: type: string - label: 'Value' + label: 'Allowed attribute values' filter_html_help: type: boolean label: 'HTML help' diff --git a/core/modules/filter/filter.install b/core/modules/filter/filter.install index 92a460c..f179de7 100644 --- a/core/modules/filter/filter.install +++ b/core/modules/filter/filter.install @@ -21,7 +21,7 @@ function filter_update_dependencies() { /** * Update the filter_html filter format schema. */ -function filter_update_8001() { +function filter_update_8401() { $config_factory = \Drupal::configFactory(); foreach ($config_factory->listAll('filter.format.') as $name) { $filter = $config_factory->getEditable($name); diff --git a/core/modules/filter/src/Plugin/Filter/FilterHtml.php b/core/modules/filter/src/Plugin/Filter/FilterHtml.php index 527a5df..639de8e 100644 --- a/core/modules/filter/src/Plugin/Filter/FilterHtml.php +++ b/core/modules/filter/src/Plugin/Filter/FilterHtml.php @@ -87,13 +87,13 @@ public function preRenderAllowedHtml($element) { * {@inheritdoc} */ public function setConfiguration(array $configuration) { - // The allowed_html setting is stored as a sequence of elements and - // attributes. The default configuration in the plugin annotation - // is deep merged into the actual configuration in FilterPluginCollection. - // So that we aren't deep merging the default configuration with the actual - // configuration of a plugin (thus making it impossible to remove an element - // in the list of defaults), we specify the default in the string - // representation and convert it to the stored array representation. + // The allowed_html setting is stored as a sequence of allowed HTML tags, + // each containing more configuration values. The default configuration in + // the plugin annotation is deep merged into the actual configuration in + // FilterPluginCollection. To prevent deep merging the default configuration + // with the actual configuration of a plugin (thus making it impossible to + // remove an element in the list of defaults), we specify the default in the + // string representation and convert it to the stored array representation. // @see \Drupal\filter\FilterPluginCollection::initializePlugin() if (is_string($configuration['settings']['allowed_html'])) { $configuration['settings']['allowed_html'] = static::convertAllowedHtmlStringToArray($configuration['settings']['allowed_html']); @@ -106,6 +106,20 @@ public function setConfiguration(array $configuration) { /** * {@inheritdoc} */ + public function defaultConfiguration() { + $default_configuration = parent::defaultConfiguration(); + // Convert the string representation of the allowed_html setting to an + // array. + // @see ::setConfiguration() + if (is_string($default_configuration['settings']['allowed_html'])) { + $default_configuration['settings']['allowed_html'] = static::convertAllowedHtmlStringToArray($default_configuration['settings']['allowed_html']); + } + return $default_configuration; + } + + /** + * {@inheritdoc} + */ public function process($text, $langcode) { $restrictions = $this->getHtmlRestrictions(); // Split the work into two parts. For filtering HTML tags out of the content