File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
app/code/Magento/PageBuilder/Model/Stage Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -49,17 +49,26 @@ public function filterHtml(string $content): string
49
49
$ this ->loggerInterface ->critical ($ e ->getMessage ());
50
50
}
51
51
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
+ }
55
64
}
56
65
$ xpath = new \DOMXPath ($ dom );
57
66
$ htmlContentTypes = $ xpath ->query (
58
67
'//*[@data-content-type="html" and not(contains(@class, "placeholder-html-code"))] '
59
68
);
60
69
foreach ($ htmlContentTypes as $ htmlContentType ) {
61
70
/* @var \DOMElement $htmlContentType */
62
- $ innerHTML = '' ;
71
+ $ innerHTML = '' ;
63
72
$ children = $ htmlContentType ->childNodes ;
64
73
foreach ($ children as $ child ) {
65
74
$ innerHTML .= $ child ->ownerDocument ->saveXML ($ child );
You can’t perform that action at this time.
0 commit comments