Verified Commit c81f5439 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
parent 6a27d762
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -356,16 +356,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);
@@ -382,7 +382,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];