G'day everyone..
Quick question, what is the best way to prevent XSS?
Currently my code isbut I feel there is a much better way.. Thanks everyonePHP Code:function clean($s){
$s = mysql_escape_string($s);
//remove unwanted tags.
$search = array("script" , "java", "<scr", "ipt>", "<>", ".location", "<!--", "<noscript", "</noscript>", "<param", "</param>", "<applet", "</applet>", "<meta", "<iframe", "</iframe>", "<form", "</form>");
// replcae with dots
$replace = "...";
// perform the replacement
$s = str_ireplace($search, $replace, $s);
// strip tags too!
$s = strip_tags($s, "<p><a><br><b><u><i><br />\r\n");
$s = stripslashes($s);
return $s;
}
+rep btw!
Moved by ReviewDude (Forum Moderator) from 'Coding & Programming'.






Reply With Quote
