Skip to content

Commit

Permalink
Allowed attributes style in AntiXss::class. (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Nov 8, 2023
1 parent a8dd639 commit c3eda15
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Helper/Encode.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ private static function cleanXSS(string $content): string|array
$antiXss = new AntiXSS();

$antiXss->removeEvilHtmlTags(['button', 'form', 'input', 'select', 'svg', 'textarea']);
$antiXss->removeEvilAttributes(['style']);

return $antiXss->xss_clean($content);
}
Expand Down
4 changes: 4 additions & 0 deletions tests/Helper/EncodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public function testSantizeXSS(): void
'<textarea></textarea>',
Encode::santizeXSS('<textarea><script>alert("XSS")</script></textarea>'),
);
$this->assertSame(
'<input type="text" value="test" style="padding-left:20px" oinvalid="" />',
Encode::santizeXSS('<input type="text" value="test" style="padding-left:20px" oinvalid="" onfocus="alert(\'XSS\')" />'),
);
}

/**
Expand Down

0 comments on commit c3eda15

Please sign in to comment.