Skip to content

Commit c39bac9

Browse files
committed
MC-15970: Page Builder Dynamic Block
1 parent e186808 commit c39bac9

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

app/code/Magento/PageBuilder/Model/Stage/HtmlFilter.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,26 @@ public function filterHtml(string $content): string
4949
$this->loggerInterface->critical($e->getMessage());
5050
}
5151
libxml_use_internal_errors($previous);
52-
// Remove all <script /> tags from output
53-
foreach (iterator_to_array($dom->getElementsByTagName('script')) as $item) {
54-
$item->parentNode->removeChild($item);
52+
// Remove all <script /> tags, on* attributes from output
53+
/** @var \DOMElement $item */
54+
foreach (iterator_to_array($dom->getElementsByTagName('*')) as $item) {
55+
if ($item->tagName === 'script') {
56+
$item->parentNode->removeChild($item);
57+
} else {
58+
foreach (iterator_to_array($item->attributes) as $attribute) {
59+
if (stripos($attribute->name, 'on') === 0) {
60+
$item->removeAttribute($attribute->name);
61+
}
62+
}
63+
}
5564
}
5665
$xpath = new \DOMXPath($dom);
5766
$htmlContentTypes = $xpath->query(
5867
'//*[@data-content-type="html" and not(contains(@class, "placeholder-html-code"))]'
5968
);
6069
foreach ($htmlContentTypes as $htmlContentType) {
6170
/* @var \DOMElement $htmlContentType */
62-
$innerHTML= '';
71+
$innerHTML = '';
6372
$children = $htmlContentType->childNodes;
6473
foreach ($children as $child) {
6574
$innerHTML .= $child->ownerDocument->saveXML($child);

0 commit comments

Comments
 (0)