Recently, I had an audit run on some of my sites by a client. One of the things they came back with was that I could be sanitizing the input data a little better as people could still cause potential harm to the database.
The function below is what I am currently using (a leftover from the old developer) but I cannot see where the potential issue may lie.
The string that gets passed through to the database will be displayed via XML which in turn is read by a Flash application.
Could anyone tell me what I might be missing? Thanks
function secure_string($string)
{
return (strip_tags(addslashes(mysql_real_escape_string(
stripslashes($string)))));
}
Better use the new PHP function filter_var() for cleaning input. New and better.
It looks like there's too much going on in that function. mysql_real_escape_string()
already escapes everything you need to escape, so there's no need to run addslashes()
on that. In fact, it could do more harm than good by escaping the backslashes mysql_real_escape_string()
creates.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With