Loading core/modules/ckeditor5/src/HTMLRestrictions.php +3 −6 Original line number Diff line number Diff line Loading @@ -305,7 +305,6 @@ public static function fromTextFormat(FilterFormatInterface $text_format): HTMLR * @return \Drupal\ckeditor5\HTMLRestrictions */ private static function unrestricted(): self { // @todo Refine in https://www.drupal.org/project/drupal/issues/3231336, including adding support for all operations. $restrictions = HTMLRestrictions::emptySet(); $restrictions->unrestricted = TRUE; return $restrictions; Loading Loading @@ -334,16 +333,14 @@ private static function fromObjectWithHtmlRestrictions(object $object): HTMLRest throw new \InvalidArgumentException(); } if ($object->getHtmlRestrictions() === FALSE) { // @todo Refine in https://www.drupal.org/project/drupal/issues/3231336 $restrictions = $object->getHTMLRestrictions(); if ($restrictions === FALSE || $restrictions === []) { return self::unrestricted(); } $restrictions = $object->getHTMLRestrictions(); $allowed = $restrictions['allowed']; // When allowing all tags on an attribute, transform FilterHtml output from // ['tag' => ['*'=> TRUE]] to ['tag' => TRUE] $allowed = $restrictions['allowed']; foreach ($allowed as $element => $attributes) { if (is_array($attributes) && isset($attributes['*']) && $attributes['*'] === TRUE) { $allowed[$element] = TRUE; Loading core/modules/ckeditor5/src/Plugin/Validation/Constraint/FundamentalCompatibilityConstraintValidator.php +5 −4 Original line number Diff line number Diff line Loading @@ -119,12 +119,13 @@ private function checkNoMarkupFilters(FilterFormatInterface $text_format, Fundam * The constraint to validate. */ private function checkHtmlRestrictionsAreCompatible(FilterFormatInterface $text_format, FundamentalCompatibilityConstraint $constraint): void { $fundamental = new HTMLRestrictions($this->pluginManager->getProvidedElements(self::FUNDAMENTAL_CKEDITOR5_PLUGINS)); $html_restrictions = $text_format->getHtmlRestrictions(); if (!isset($html_restrictions['allowed'])) { $html_restrictions = HTMLRestrictions::fromTextFormat($text_format); if ($html_restrictions->isUnrestricted()) { return; } if (!$fundamental->diff(HTMLRestrictions::fromTextFormat($text_format))->allowsNothing()) { $fundamental = new HTMLRestrictions($this->pluginManager->getProvidedElements(self::FUNDAMENTAL_CKEDITOR5_PLUGINS)); if (!$fundamental->diff($html_restrictions)->allowsNothing()) { $offending_filter = static::findHtmlRestrictorFilterNotAllowingTags($text_format, $fundamental); $this->context->buildViolation($constraint->nonAllowedElementsMessage) ->setParameter('%filter_label', (string) $offending_filter->getLabel()) Loading Loading
core/modules/ckeditor5/src/HTMLRestrictions.php +3 −6 Original line number Diff line number Diff line Loading @@ -305,7 +305,6 @@ public static function fromTextFormat(FilterFormatInterface $text_format): HTMLR * @return \Drupal\ckeditor5\HTMLRestrictions */ private static function unrestricted(): self { // @todo Refine in https://www.drupal.org/project/drupal/issues/3231336, including adding support for all operations. $restrictions = HTMLRestrictions::emptySet(); $restrictions->unrestricted = TRUE; return $restrictions; Loading Loading @@ -334,16 +333,14 @@ private static function fromObjectWithHtmlRestrictions(object $object): HTMLRest throw new \InvalidArgumentException(); } if ($object->getHtmlRestrictions() === FALSE) { // @todo Refine in https://www.drupal.org/project/drupal/issues/3231336 $restrictions = $object->getHTMLRestrictions(); if ($restrictions === FALSE || $restrictions === []) { return self::unrestricted(); } $restrictions = $object->getHTMLRestrictions(); $allowed = $restrictions['allowed']; // When allowing all tags on an attribute, transform FilterHtml output from // ['tag' => ['*'=> TRUE]] to ['tag' => TRUE] $allowed = $restrictions['allowed']; foreach ($allowed as $element => $attributes) { if (is_array($attributes) && isset($attributes['*']) && $attributes['*'] === TRUE) { $allowed[$element] = TRUE; Loading
core/modules/ckeditor5/src/Plugin/Validation/Constraint/FundamentalCompatibilityConstraintValidator.php +5 −4 Original line number Diff line number Diff line Loading @@ -119,12 +119,13 @@ private function checkNoMarkupFilters(FilterFormatInterface $text_format, Fundam * The constraint to validate. */ private function checkHtmlRestrictionsAreCompatible(FilterFormatInterface $text_format, FundamentalCompatibilityConstraint $constraint): void { $fundamental = new HTMLRestrictions($this->pluginManager->getProvidedElements(self::FUNDAMENTAL_CKEDITOR5_PLUGINS)); $html_restrictions = $text_format->getHtmlRestrictions(); if (!isset($html_restrictions['allowed'])) { $html_restrictions = HTMLRestrictions::fromTextFormat($text_format); if ($html_restrictions->isUnrestricted()) { return; } if (!$fundamental->diff(HTMLRestrictions::fromTextFormat($text_format))->allowsNothing()) { $fundamental = new HTMLRestrictions($this->pluginManager->getProvidedElements(self::FUNDAMENTAL_CKEDITOR5_PLUGINS)); if (!$fundamental->diff($html_restrictions)->allowsNothing()) { $offending_filter = static::findHtmlRestrictorFilterNotAllowingTags($text_format, $fundamental); $this->context->buildViolation($constraint->nonAllowedElementsMessage) ->setParameter('%filter_label', (string) $offending_filter->getLabel()) Loading