From f21fe22563b14441d6cd5e648efe070f5f045a37 Mon Sep 17 00:00:00 2001 From: catch Date: Thu, 28 Mar 2024 21:18:11 +0000 Subject: [PATCH] Issue #3436478 by longwave: Use regex instead of DOM parsing in BigPipe::getPlaceholderOrder() --- core/modules/big_pipe/src/Render/BigPipe.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/core/modules/big_pipe/src/Render/BigPipe.php b/core/modules/big_pipe/src/Render/BigPipe.php index 1eab778c0c2..d7de08e29e3 100644 --- a/core/modules/big_pipe/src/Render/BigPipe.php +++ b/core/modules/big_pipe/src/Render/BigPipe.php @@ -700,7 +700,9 @@ EOF; /** * Gets the BigPipe placeholder order. * - * Determines the order in which BigPipe placeholders are executed. + * Determines the order in which BigPipe placeholders are executed. It is + * safe to use a regular expression here as the HTML is statically created in + * \Drupal\big_pipe\Render\Placeholder\BigPipeStrategy::createBigPipeJsPlaceholder(). * * @param string $html * HTML markup. @@ -718,13 +720,10 @@ EOF; * first occurrence. */ protected function getPlaceholderOrder($html, $placeholders) { - $placeholder_ids = []; - $dom = Html::load($html); - $xpath = new \DOMXPath($dom); - foreach ($xpath->query('//span[@data-big-pipe-placeholder-id]') as $node) { - $placeholder_ids[] = Html::escape($node->getAttribute('data-big-pipe-placeholder-id')); + if (preg_match_all('//', $html, $matches)) { + return array_unique($matches[1]); } - return array_unique($placeholder_ids); + return []; } /**