The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
Does the DB query_insert handle escaping of nasty characters (parenthesis, commas, quotes, etc.) - to avoid SQL insertion attacks, or just plain SQL corruption?
(I know the Perl DBI does all of this for you, saving Perl programmers from many of the headaches - and breakins - common to PHP) Also, why does the vB code *never* use the query_insert method? |
#2
|
||||
|
||||
![]()
It doesn't, it's just a shortcut.
But AFAIK the new DB Class supports prepared statements, if that is what you want. Edit: mysqli supports it, the new DB class doesn't. |
#3
|
|||
|
|||
![]()
Yeah, mysqli is great. Once you've used the power of DBI over roll-your-own-string-SQL, you can't go back.
Kirby, then, can I ask you: What is the best way, in vB / PHP, to ensure that all data passed to the INSERT is quoted and escaped properly? (Doing it by hand can get tricky, with nulls, quotes, slashes, charsets, etc. - especially when you don't want to strip anything, just get it to the DB safely). |
#4
|
||||
|
||||
![]()
addslashes();
but make sure you use it on a new variable, not $_POST/$_GET/$_REQUEST/$_SERVER/$_COOKIE/etc |
#5
|
||||
|
||||
![]()
$db->escape_string()
|
#6
|
||||
|
||||
![]()
$db->escape_string($string) is the best way AFAIK.
|
#7
|
|||
|
|||
![]()
Yeah, addslashes is not sufficient, for a lot of reasons.
I took a look at escape_string - it defaults to mysql_escape_string(), which is good, except: Quote:
It's a shame that PHP programmers have to go through such hoolahoops for what should be basic DB class functionality (again, see DBI for an example)... Building your own string is not only ineffecient, (and a hassle for the programmer) - it opens the door to a lot of security issues and internationalization bugs |
#8
|
||||
|
||||
![]() Quote:
![]() PHP Code:
I guess vB does not use prepared statements due to compatibilty reasons. |
#9
|
|||
|
|||
![]()
Kirbs, you are the master!
|
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|