@@ -250,6 +250,40 @@ public function testComplexHtmlFiltering(): void
250250 $ this ->assertStringNotContainsString ('onmouseover ' , $ result );
251251 }
252252
253+ public function testRemoveAttributesWithUnquotedValues (): void
254+ {
255+ $ html = '<img src=x onerror=alert(1)> ' ;
256+ $ result = Filter::removeAttributes ($ html );
257+
258+ $ this ->assertStringNotContainsString ('onerror ' , $ result );
259+ }
260+
261+ public function testRemoveAttributesWithSingleQuotedValues (): void
262+ {
263+ $ html = "<img src='x' onerror='alert(1)'> " ;
264+ $ result = Filter::removeAttributes ($ html );
265+
266+ $ this ->assertStringNotContainsString ('onerror ' , $ result );
267+ }
268+
269+ public function testRemoveAttributesWithSvgOnload (): void
270+ {
271+ $ html = '<svg onload=alert(1)> ' ;
272+ $ result = Filter::removeAttributes ($ html );
273+
274+ $ this ->assertStringNotContainsString ('onload ' , $ result );
275+ }
276+
277+ public function testRemoveAttributesWithMixedQuoteStyles (): void
278+ {
279+ $ html = '<div class="safe" onclick=alert(1) style= \'color:red \' onmouseover="steal()"> ' ;
280+ $ result = Filter::removeAttributes ($ html );
281+
282+ $ this ->assertStringContainsString ('class="safe" ' , $ result );
283+ $ this ->assertStringNotContainsString ('onclick ' , $ result );
284+ $ this ->assertStringNotContainsString ('onmouseover ' , $ result );
285+ }
286+
253287 protected function tearDown (): void
254288 {
255289 unset($ _GET ['test_var ' ], $ _GET ['special_test ' ], $ _POST ['name ' ], $ _POST ['email ' ]);
0 commit comments