@@ -297,6 +297,40 @@ public function testComplexHtmlFiltering(): void
297297 $ this ->assertStringNotContainsString ('onmouseover ' , $ result );
298298 }
299299
300+ public function testRemoveAttributesWithUnquotedValues (): void
301+ {
302+ $ html = '<img src=x onerror=alert(1)> ' ;
303+ $ result = Filter::removeAttributes ($ html );
304+
305+ $ this ->assertStringNotContainsString ('onerror ' , $ result );
306+ }
307+
308+ public function testRemoveAttributesWithSingleQuotedValues (): void
309+ {
310+ $ html = "<img src='x' onerror='alert(1)'> " ;
311+ $ result = Filter::removeAttributes ($ html );
312+
313+ $ this ->assertStringNotContainsString ('onerror ' , $ result );
314+ }
315+
316+ public function testRemoveAttributesWithSvgOnload (): void
317+ {
318+ $ html = '<svg onload=alert(1)> ' ;
319+ $ result = Filter::removeAttributes ($ html );
320+
321+ $ this ->assertStringNotContainsString ('onload ' , $ result );
322+ }
323+
324+ public function testRemoveAttributesWithMixedQuoteStyles (): void
325+ {
326+ $ html = '<div class="safe" onclick=alert(1) style= \'color:red \' onmouseover="steal()"> ' ;
327+ $ result = Filter::removeAttributes ($ html );
328+
329+ $ this ->assertStringContainsString ('class="safe" ' , $ result );
330+ $ this ->assertStringNotContainsString ('onclick ' , $ result );
331+ $ this ->assertStringNotContainsString ('onmouseover ' , $ result );
332+ }
333+
300334 protected function tearDown (): void
301335 {
302336 unset($ _GET ['test_var ' ], $ _GET ['special_test ' ], $ _POST ['name ' ], $ _POST ['email ' ]);
0 commit comments