Thread: string.escape()
View Single Post
  #3  
Old 01-20-2010, 02:23 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by LoneAngelIbesu View Post
... Wha? That's what escaping is, and the point of escaping is to prevent SQL injections, not because SQLite can't handle quotation marks.
I'm tempted to say the same thing to you: wha?

If you feed SQLite as string such as:
PHP Code:
test "foo" bar 
it will enter perfectly fine:

PHP Code:
INSERT INTO table (columnVALUES ('test "foo" bar'
str.escape() places backslashes in front of quotations. Basically, it does:
PHP Code:
INSERT INTO table (columnVALUES ('test \"foo\" bar'
It's literally inserted into SQLite as:

PHP Code:
test \"foo\" bar 

Unlike single quotations, quotation marks don't need to be escaped, and escaping them only makes strings enter incorrectly.

I think maybe you thought I was referring to single quotes instead of quotation marks in my post, sorry; could've been more clear about that.
__________________
Reply With Quote