sqlite escape string
#5

Quote:
Originally Posted by DavidBilla
Посмотреть сообщение
why should strings be escaped
To filter out special characters that the SQL interpreter may read as part of the query rather than part of the string. You will either get an erroneous query or an unexpected result which may prove useful to a hacker. For example the character ' (single quote) is used to denote strings, but if it appears in a string itself it must be escape, for example:
PHP код:
... WHERE name='O'Hare'; 
Would produce an error
PHP код:
... WHERE name='O\'hare'
Would not produce an error.

This is the simple case, but it is also necessary to protect against people who could exploit this by supplying a weird input, like
PHP код:
zrtpqdfgh' OR 1=1; -- 
In which case the unescaped query would look like:
PHP код:
... WHERE name='zrtpqdfgh' OR 1=1; --'; 
That will likely yield the first account in the database which is nearly always the one of the administrator, leading to potentially dangerous situations.

Quote:
Originally Posted by DavidBilla
Посмотреть сообщение
what are the cases where it should be used
Any time you expect user input. That includes dialogs, chat text and command text.
Reply


Messages In This Thread
sqlite escape string - by DavidBilla - 22.10.2015, 08:19
Re: sqlite escape string - by PrO.GameR - 22.10.2015, 08:27
Re: sqlite escape string - by DaniceMcHarley - 22.10.2015, 08:37
Re: sqlite escape string - by rymax99 - 22.10.2015, 09:37
Re: sqlite escape string - by Vince - 22.10.2015, 09:48
Re: sqlite escape string - by PrO.GameR - 22.10.2015, 10:48

Forum Jump:


Users browsing this thread: 1 Guest(s)