Input filtering
Posted: Fri Jun 05, 2009 12:02 pm
Hi all,
I've just chucked together a quick brute force strip tags function.
It seems to work happly at the moment, and I've even used some XSS example code to test it out, and all seems to be ok.
I'm now thinking of introducing it as a standard eliment to clean all input before it hits the database, or is printed to screen. This will come into play before I use stripslashes() and mysql_real_escape(). I don't want users injecting HTML code into any forms.
Is this a good idea, or is there any other processing I should do before user input is submitted to the database as part of an SQL?
Thanks
Matt
I've just chucked together a quick brute force strip tags function.
Code: Select all
function StripTags($string) {
$string = $this->EncodeUTF8($string);
$string = preg_replace("/\<(.*?)\>(.*?)\<\/(.*?)\>/u", "$2", $string);
$string = strip_tags($string);
return $string;
}
I'm now thinking of introducing it as a standard eliment to clean all input before it hits the database, or is printed to screen. This will come into play before I use stripslashes() and mysql_real_escape(). I don't want users injecting HTML code into any forms.
Is this a good idea, or is there any other processing I should do before user input is submitted to the database as part of an SQL?
Thanks
Matt