@@ -88,7 +88,7 @@ public function render(array $params): array
88
88
89
89
if ($ block ->isActive ()) {
90
90
$ directiveResult = $ this ->widgetDirectiveRenderer ->render ($ params );
91
- $ result = $ this ->removeScriptTags ($ directiveResult );
91
+ $ result[ ' content ' ] = $ this ->removeScriptTags ($ directiveResult[ ' content ' ] );
92
92
} else {
93
93
$ result ['error ' ] = __ ('Block disabled ' );
94
94
}
@@ -99,26 +99,23 @@ public function render(array $params): array
99
99
/**
100
100
* Remove script tag from html
101
101
*
102
- * @param array $directiveResult
103
- * @return array
102
+ * @param string $content
103
+ * @return string
104
104
*/
105
- private function removeScriptTags (array $ directiveResult ): array
105
+ private function removeScriptTags (string $ content ): string
106
106
{
107
107
$ dom = new \DOMDocument ();
108
108
try {
109
109
//this code is required because of https://bugs.php.net/bug.php?id=60021
110
110
$ previous = libxml_use_internal_errors (true );
111
- $ dom ->loadHTML ($ directiveResult [ ' content ' ] );
111
+ $ dom ->loadHTML ($ content );
112
112
} catch (\Exception $ e ) {
113
113
$ this ->loggerInterface ->critical ($ e ->getMessage ());
114
114
}
115
115
libxml_use_internal_errors ($ previous );
116
116
foreach (iterator_to_array ($ dom ->getElementsByTagName ('script ' )) as $ item ) {
117
117
$ item ->parentNode ->removeChild ($ item );
118
118
}
119
- return [
120
- 'content ' => $ dom ->saveHTML (),
121
- 'error ' => $ directiveResult ['error ' ]
122
- ];
119
+ return $ dom ->saveHTML ();
123
120
}
124
121
}
0 commit comments