Skip to content
Snippets Groups Projects
Verified Commit 6e2e2cd0 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3326778 by Graber, Wim Leers, Web-Beest, catch: TypeError:...

Issue #3326778 by Graber, Wim Leers, Web-Beest, catch: TypeError: Drupal\ckeditor5\HTMLRestrictions::__construct(): Argument #1 ($elements) must be of type array, Drupal\ckeditor5\HTMLRestrictions given
parent d98f5613
No related branches found
No related tags found
No related merge requests found
......@@ -149,11 +149,11 @@ private function checkHtmlRestrictionsMatch(EditorInterface $text_editor, Fundam
);
$enabled_plugins = array_keys($this->pluginManager->getEnabledDefinitions($text_editor));
$provided = $this->pluginManager->getProvidedElements($enabled_plugins, $text_editor);
$provided_elements = $this->pluginManager->getProvidedElements($enabled_plugins, $text_editor);
$provided = new HTMLRestrictions($provided_elements);
foreach ($html_restrictor_filters as $filter_plugin_id => $filter) {
$allowed = HTMLRestrictions::fromFilterPluginInstance($filter);
$provided = new HTMLRestrictions($provided);
$diff_allowed = $allowed->diff($provided);
$diff_elements = $provided->diff($allowed);
......
......@@ -1466,4 +1466,64 @@ public function providerPair(): array {
return $data;
}
/**
* Tests that validation works with >1 enabled HTML restrictor filters.
*
* @covers \Drupal\ckeditor5\Plugin\Validation\Constraint\FundamentalCompatibilityConstraintValidator::checkHtmlRestrictionsMatch()
*/
public function testMultipleHtmlRestrictingFilters(): void {
$this->container->get('module_installer')->install(['filter_test']);
$text_format = FilterFormat::create([
'format' => 'very_restricted',
'name' => $this->randomMachineName(),
'filters' => [
// The first filter of type TYPE_HTML_RESTRICTOR.
'filter_html' => [
'id' => 'filter_html',
'provider' => 'filter',
'status' => TRUE,
'weight' => 0,
'settings' => [
'allowed_html' => "<p> <br>",
'filter_html_help' => TRUE,
'filter_html_nofollow' => TRUE,
],
],
// The second filter of type TYPE_HTML_RESTRICTOR. Configure this to
// allow exactly what the first filter allows.
'filter_test_restrict_tags_and_attributes' => [
'id' => 'filter_test_restrict_tags_and_attributes',
'provider' => 'filter_test',
'status' => TRUE,
'settings' => [
'restrictions' => [
'allowed' => [
'p' => FALSE,
'br' => FALSE,
'*' => [
'dir' => ['ltr' => TRUE, 'rtl' => TRUE],
'lang' => TRUE,
],
],
],
],
],
],
]);
$text_editor = Editor::create([
'format' => 'very_restricted',
'editor' => 'ckeditor5',
'settings' => [
'toolbar' => [
'items' => [],
],
'plugins' => [],
],
'image_upload' => [],
]);
$this->assertSame([], $this->validatePairToViolationsArray($text_editor, $text_format, TRUE));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment