Last active
March 5, 2022 01:01
-
-
Save irazasyed/4cfecc00a1928fd4aa73 to your computer and use it in GitHub Desktop.
PHP: XSS Protection.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Prevent XSS - Trims and Sanitizes GET/POST Data */ | |
$_GET = array_map(function ($param) { | |
return strip_tags(trim(addslashes(htmlspecialchars($param)))); | |
}, $_GET); | |
$_POST = array_map(function ($param) { | |
return htmlspecialchars(addslashes(trim($param))); | |
}, $_POST); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment