diff --git a/core/modules/editor/tests/editor_private_test/config/install/filter.format.private_images.yml b/core/modules/editor/tests/editor_private_test/config/install/filter.format.private_images.yml index 261bd90..dc4dd04 100644 --- a/core/modules/editor/tests/editor_private_test/config/install/filter.format.private_images.yml +++ b/core/modules/editor/tests/editor_private_test/config/install/filter.format.private_images.yml @@ -15,7 +15,12 @@ filters: status: false weight: -10 settings: - allowed_html: '' + allowed_html: + img: + src: '*' + alt: '*' + data-entity-type: '*' + data-entity-uuid: '*' filter_html_help: true filter_html_nofollow: false dependencies: diff --git a/core/modules/filter/config/schema/filter.schema.yml b/core/modules/filter/config/schema/filter.schema.yml index b45a475..6756f1e 100644 --- a/core/modules/filter/config/schema/filter.schema.yml +++ b/core/modules/filter/config/schema/filter.schema.yml @@ -51,8 +51,14 @@ filter_settings.filter_html: label: 'Filter HTML' mapping: allowed_html: - type: string + type: sequence label: 'Allowed HTML' + sequence: + type: sequence + label: 'Attributes' + sequence: + type: string + label: 'Value' filter_html_help: type: boolean label: 'HTML help' diff --git a/core/modules/filter/filter.install b/core/modules/filter/filter.install new file mode 100644 index 0000000..bfc0466 --- /dev/null +++ b/core/modules/filter/filter.install @@ -0,0 +1,27 @@ +listAll('filter.format.') as $name) { + $filter = $config_factory->getEditable($name); + $allowed_html = $filter->get('filters.filter_html.settings.allowed_html'); + if ($allowed_html !== NULL) { + $plugin_class = new FilterHtml([], '', ['provider' => 'foo']); + $generate_method = new ReflectionMethod(FilterHtml::class, 'generateAllowedHtmlSettings'); + $generate_method->setAccessible(TRUE); + $updated_allowed_html = $generate_method->invoke($plugin_class, $allowed_html); + $filter->set('filters.filter_html.settings.allowed_html', $updated_allowed_html); + $filter->save(); + } + } +} diff --git a/core/modules/filter/src/Plugin/Filter/FilterHtml.php b/core/modules/filter/src/Plugin/Filter/FilterHtml.php index 882bcc0..76a240d 100644 --- a/core/modules/filter/src/Plugin/Filter/FilterHtml.php +++ b/core/modules/filter/src/Plugin/Filter/FilterHtml.php @@ -15,12 +15,14 @@ * by only having the attribute name, or allowing a fixed list of values, or * allowing a value with a wildcard prefix. * + * @todo, figure out how to set allowed_html without forcing certain elements. + * * @Filter( * id = "filter_html", * title = @Translation("Limit allowed HTML tags and correct faulty HTML"), * type = Drupal\filter\Plugin\FilterInterface::TYPE_HTML_RESTRICTOR, * settings = { - * "allowed_html" = "