diff --git a/core/modules/big_pipe/src/Render/BigPipe.php b/core/modules/big_pipe/src/Render/BigPipe.php index 1eab778c0c2106e1c393d4bd7c1dbceee3ff6351..d7de08e29e37d8e2f8d4dec6a8397513876c1967 100644 --- a/core/modules/big_pipe/src/Render/BigPipe.php +++ b/core/modules/big_pipe/src/Render/BigPipe.php @@ -700,7 +700,9 @@ protected function renderPlaceholder($placeholder, array $placeholder_render_arr /** * 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 @@ protected function renderPlaceholder($placeholder, array $placeholder_render_arr * 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('/<span data-big-pipe-placeholder-id="([^"]*)">/', $html, $matches)) { + return array_unique($matches[1]); } - return array_unique($placeholder_ids); + return []; } /**