function HTMLRestrictions::validateAllowedRestrictionsPhase5

Same name in other branches
  1. 9 core/modules/ckeditor5/src/HTMLRestrictions.php \Drupal\ckeditor5\HTMLRestrictions::validateAllowedRestrictionsPhase5()
  2. 10 core/modules/ckeditor5/src/HTMLRestrictions.php \Drupal\ckeditor5\HTMLRestrictions::validateAllowedRestrictionsPhase5()

Validates allowed elements — phase 5: disallowed attribute overrides.

Explicit overrides of globally disallowed attributes are considered errors. For example: `<p style>`, `<a onclick>` are considered errors when the `style` and `on*` attributes are globally disallowed.

Implicit overrides are not treated as errors: if all attributes are allowed on a tag, globally disallowed attributes still apply. For example: `<p *>` allows all attributes on `<p>`, but still won't allow globally disallowed attributes.

Parameters

array $elements: The allowed elements.

Throws

\InvalidArgumentException

1 call to HTMLRestrictions::validateAllowedRestrictionsPhase5()
HTMLRestrictions::__construct in core/modules/ckeditor5/src/HTMLRestrictions.php
Constructs a set of HTML restrictions.

File

core/modules/ckeditor5/src/HTMLRestrictions.php, line 316

Class

HTMLRestrictions
Represents a set of HTML restrictions.

Namespace

Drupal\ckeditor5

Code

private static function validateAllowedRestrictionsPhase5(array $elements) : void {
    $conflict = self::findElementsOverridingGloballyDisallowedAttributes($elements);
    if ($conflict) {
        [
            $globally_disallowed_attribute_restrictions,
            $elements_overriding_globally_disallowed_attributes,
        ] = $conflict;
        throw new \InvalidArgumentException(sprintf('The attribute restrictions in "%s" are allowing attributes "%s" that are disallowed by the special "*" global attribute restrictions.', implode(' ', (new self($elements_overriding_globally_disallowed_attributes))->toCKEditor5ElementsArray()), implode('", "', array_keys($globally_disallowed_attribute_restrictions))));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.