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

Issue #3280602 by larowlan, DanielVeza, Wim Leers, mstrelan: Exceptions for...

Issue #3280602 by larowlan, DanielVeza, Wim Leers, mstrelan: Exceptions for CKEditor 5 plugin definitions containing wildcard tags when PHP is built with libxml 2.9.14

(cherry picked from commit c81f5439)
parent a9a06960
Branches
Tags
4 merge requests!2496Issue #3222757 by lauriii, Wim Leers, nod_, rachel_norfolk, itmaybejj,...,!2366Issue #3285105 by Daniel Arend,!2304Issue #3258987: Class "Drupal\Core\Utility\Error" not found in _drupal_error_handler_real() due to bug in PHP 8.1.0-8.1.5,!1387Draft: Resolve #2511878 "Support enclosure field"
......@@ -365,16 +365,16 @@ private static function fromObjectWithHtmlRestrictions(object $object): HTMLRest
*/
public static function fromString(string $elements_string): HTMLRestrictions {
// Preprocess wildcard tags: convert `<$text-container>` to
// `<__preprocessed-wildcard-text-container__>` and `<*>` to
// `<__preprocessed-global-attribute__>`.
// `<preprocessed-wildcard-text-container__>` and `<*>` to
// `<preprocessed-global-attribute__>`.
// Note: unknown wildcard tags will trigger a validation error in
// ::validateAllowedRestrictionsPhase1().
$replaced_wildcard_tags = [];
$elements_string = preg_replace_callback('/<(\$[a-z][0-9a-z\-]*|\*)/', function ($matches) use (&$replaced_wildcard_tags) {
$wildcard_tag_name = $matches[1];
$replacement = $wildcard_tag_name === '*'
? '__preprocessed-global-attribute__'
: sprintf("__preprocessed-wildcard-%s__", substr($wildcard_tag_name, 1));
? 'preprocessed-global-attribute__'
: sprintf("preprocessed-wildcard-%s__", substr($wildcard_tag_name, 1));
$replaced_wildcard_tags[$replacement] = $wildcard_tag_name;
return "<$replacement";
}, $elements_string);
......@@ -391,7 +391,7 @@ public static function fromString(string $elements_string): HTMLRestrictions {
unset($allowed_elements['__zqh6vxfbk3cg__']);
// Postprocess tag wildcards: convert
// `<__preprocessed-wildcard-text-container__>` to `<$text-container>`.
// `<preprocessed-wildcard-text-container__>` to `<$text-container>`.
foreach ($replaced_wildcard_tags as $processed => $original) {
if (isset($allowed_elements[$processed])) {
$allowed_elements[$original] = $allowed_elements[$processed];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment