Skip to content

Commit 161d3c4

Browse files
committed
MC-34846: [Page Builder] “Order by SKU” Widget is displayed incorrectly on the Storefront
- Mask only "x-magento-template" scripts
1 parent 1369bad commit 161d3c4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

app/code/Magento/PageBuilder/Model/Filter/Template.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ private function getMediaQuery(string $view) : ?string
361361
}
362362

363363
/**
364-
* Masks script tags in html content before loading it into DOM parser
364+
* Masks "x-magento-template" script tags in html content before loading it into DOM parser
365365
*
366366
* DOMDocument::loadHTML() will remove any closing tag inside script tag and will result in broken html template
367367
*
@@ -373,7 +373,7 @@ private function maskScriptTags(string $content): string
373373
{
374374
$tag = 'script';
375375
$content = preg_replace_callback(
376-
"#<{$tag}[^>]+?>.*?</{$tag}>#is",
376+
sprintf('#<%1$s[^>]*type="text/x-magento-template\"[^>]*>.*?</%1$s>#is', $tag),
377377
function ($matches) {
378378
$key = $this->mathRandom->getRandomString(32, $this->mathRandom::CHARS_LOWERS);
379379
$this->scripts[$key] = $matches[0];
@@ -385,7 +385,7 @@ function ($matches) {
385385
}
386386

387387
/**
388-
* Replaces masked script tags with their corresponding content
388+
* Replaces masked "x-magento-template" script tags with their corresponding content
389389
*
390390
* @param string $content
391391
* @return string

0 commit comments

Comments
 (0)