felipe Sun Feb 15 21:48:54 2009 UTC
Modified files:
/php-src/ext/pdo_firebird firebird_driver.c
Log:
- Fixed bug #47398 (PDO_Firebird doesn't implements quoter correctly)
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_firebird/firebird_driver.c?r1=1.25&r2=1.26&diff_format=u
Index: php-src/ext/pdo_firebird/firebird_driver.c
diff -u php-src/ext/pdo_firebird/firebird_driver.c:1.25
php-src/ext/pdo_firebird/firebird_driver.c:1.26
--- php-src/ext/pdo_firebird/firebird_driver.c:1.25 Wed Dec 31 11:12:34 2008
+++ php-src/ext/pdo_firebird/firebird_driver.c Sun Feb 15 21:48:54 2009
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: firebird_driver.c,v 1.25 2008/12/31 11:12:34 sebastian Exp $ */
+/* $Id: firebird_driver.c,v 1.26 2009/02/15 21:48:54 felipe Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -274,38 +274,38 @@
char **quoted, int *quotedlen, enum pdo_param_type paramtype TSRMLS_DC)
{
int qcount = 0;
- char const *c;
+ char const *co, *l, *r;
+ char *c;
+ if (!unquotedlen) {
+ *quotedlen = 2;
+ *quoted = emalloc(*quotedlen+1);
+ strcpy(*quoted, "''");
+ return 1;
+ }
+
/* Firebird only requires single quotes to be doubled if string lengths
are used */
-
/* count the number of ' characters */
- for (c = unquoted; (c = strchr(c,'\'')); qcount++, c++);
+ for (co = unquoted; (co = strchr(co,'\'')); qcount++, co++);
- if (!qcount) {
- return 0;
- } else {
- char const *l, *r;
- char *c;
-
- *quotedlen = unquotedlen + qcount;
- *quoted = c = emalloc(*quotedlen+1);
-
- /* foreach (chunk that ends in a quote) */
- for (l = unquoted; (r = strchr(l,'\'')); l = r+1) {
-
- /* copy the chunk */
- strncpy(c, l, r-l);
- c += (r-l);
-
- /* add the second quote */
- *c++ = '\'';
- }
-
- /* copy the remainder */
- strncpy(c, l, *quotedlen-(c-*quoted));
-
- return 1;
- }
+ *quotedlen = unquotedlen + qcount + 2;
+ *quoted = c = emalloc(*quotedlen+1);
+ *c++ = '\'';
+
+ /* foreach (chunk that ends in a quote) */
+ for (l = unquoted; (r = strchr(l,'\'')); l = r+1) {
+ strncpy(c, l, r-l+1);
+ c += (r-l+1);
+ /* add the second quote */
+ *c++ = '\'';
+ }
+
+ /* copy the remainder */
+ strncpy(c, l, *quotedlen-(c-*quoted)-1);
+ (*quoted)[*quotedlen-1] = '\'';
+ (*quoted)[*quotedlen] = '\0';
+
+ return 1;
}
/* }}} */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php