One day I was talking with a friend about one of his server applications for a little flash game. The server communicates with a mysql database. And I found this request:
"UPDATE phpbb_users SET patojdur = '" + this.score + "' WHERE user_id = '" + this.user_id + "'"
As this.score is data entered by the user, I asked him if it wasn't unsafe to put that directly in the SQL request, and take the risk of an SQL injection.
But he answered me: "No, because this.score is an user_request.split("'")[1]
, the split is protecting me and you can't put a '
to inject."
My question isn't if he made the right choice by doing that, because I know he won't change his mind, but What he said made me curious about a thing: is split really safe? Does it really prevent the splitted character to pass whatever you do? Or even if it's risky, put a var.split("'")
finally prevent you from '
injection?
Edit: I've read the following question but mine is specific to the Split method, and doesn't apply only on SQL database, in other word my question is:
Does var.split('c')
really prevent c to be in the final string?