#34837 [Opn->WFx]: sqlite_escape_string() fails to escape double quotes correctly

From: Date: Wed, 12 Oct 2005 10:50:20 +0000
Subject: #34837 [Opn->WFx]: sqlite_escape_string() fails to escape double quotes correctly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-86450@lists.php.net to get a copy of this message
ID: 34837 Updated by: tony2001@php.net Reported By: veter at oxarchdigital dot com -Status: Open +Status: Wont fix Bug Type: SQLite related Operating System: Win32 PHP Version: 5.1.0RC1 New Comment: sqlite_escape_string() is just wrapper for sqlite_mprintf("%q", string) call. In SQLite v2 this call doubles only single quotes, while in SQLite v3 it doubles ",' and \. I don't think sqlite_escape_string() will change ever, mostly for BC reasons. SQLite v3 is supported by pdo_sqlite. Previous Comments: ------------------------------------------------------------------------ [2005-10-12 12:28:39] veter at oxarchdigital dot com Description: ------------ sqlite_escape_string() replaces single quotes fine (' becomes ''), whilst it fails to replace double quotes, which are still used in some odd SQL code, and which are confusing SQLite. Should there be another optional parameter selecting which quotes to escape? Reproduce code: --------------- $sValue = sqlite_escape_string('This string contains "double quotes"'); // Note " not ' used in this SQL statement! $sQuery = 'INSERT INTO testtab(testfld) VALUES("' . $sValue . '")'; sqlite_query($linkID, $sQuery); Expected result: ---------------- Successful INSERT operation Actual result: -------------- SQL failure ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34837&edit=1

« previous php.bugs (#86450) next »