apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roo...@apache.org
Subject svn commit: r372724 - in /apr/apr-util/trunk: CHANGES dbd/apr_dbd_sqlite2.c dbd/apr_dbd_sqlite3.c test/testdbd.c
Date Fri, 27 Jan 2006 04:28:27 GMT
Author: rooneg
Date: Thu Jan 26 20:28:25 2006
New Revision: 372724

URL: http://svn.apache.org/viewcvs?rev=372724&view=rev
Log:
Fix the escape implementation in the sqlite dbd back ends.

Submitted by: Ronen Mizrahi <ronen tversity.com>
Tests by: rooneg

* dbd/apr_dbd_sqlite2.c
  (dbd_sqlite_escape): Use the %q format string.

* dbd/apr_dbd_sqlite3.c
  (dbd_sqlite_escape): Ditto.

* test/testdbd.c
  (test_escape): New test.
  (test_dbd_generic): Call test_escape.

* CHANGES: Note fix.

Modified:
    apr/apr-util/trunk/CHANGES
    apr/apr-util/trunk/dbd/apr_dbd_sqlite2.c
    apr/apr-util/trunk/dbd/apr_dbd_sqlite3.c
    apr/apr-util/trunk/test/testdbd.c

Modified: apr/apr-util/trunk/CHANGES
URL: http://svn.apache.org/viewcvs/apr/apr-util/trunk/CHANGES?rev=372724&r1=372723&r2=372724&view=diff
==============================================================================
--- apr/apr-util/trunk/CHANGES (original)
+++ apr/apr-util/trunk/CHANGES Thu Jan 26 20:28:25 2006
@@ -1,5 +1,9 @@
 Changes with APR-util 1.3.0
 
+  *) Fix the escape implementations for the sqlite2 and sqlite3 dbd
+     back ends.
+     [Ronen Mizrahi <ronen tversity.com>, Garrett Rooney]
+
   *) On platforms that use autoconf stop automatically linking against
      apr-iconv when an apr-iconv source dir is found in ../apr-iconv.
      Instead, add a --with-apr-iconv option to configure that lets you

Modified: apr/apr-util/trunk/dbd/apr_dbd_sqlite2.c
URL: http://svn.apache.org/viewcvs/apr/apr-util/trunk/dbd/apr_dbd_sqlite2.c?rev=372724&r1=372723&r2=372724&view=diff
==============================================================================
--- apr/apr-util/trunk/dbd/apr_dbd_sqlite2.c (original)
+++ apr/apr-util/trunk/dbd/apr_dbd_sqlite2.c Thu Jan 26 20:28:25 2006
@@ -211,7 +211,7 @@
 static const char *dbd_sqlite_escape(apr_pool_t * pool, const char *arg,
                                      apr_dbd_t * sql)
 {
-    char *ret = sqlite_mprintf(arg);
+    char *ret = sqlite_mprintf("%q", arg);
     apr_pool_cleanup_register(pool, ret, (void *) sqlite_freemem,
                               apr_pool_cleanup_null);
     return ret;

Modified: apr/apr-util/trunk/dbd/apr_dbd_sqlite3.c
URL: http://svn.apache.org/viewcvs/apr/apr-util/trunk/dbd/apr_dbd_sqlite3.c?rev=372724&r1=372723&r2=372724&view=diff
==============================================================================
--- apr/apr-util/trunk/dbd/apr_dbd_sqlite3.c (original)
+++ apr/apr-util/trunk/dbd/apr_dbd_sqlite3.c Thu Jan 26 20:28:25 2006
@@ -260,7 +260,7 @@
 static const char *dbd_sqlite3_escape(apr_pool_t *pool, const char *arg,
                                       apr_dbd_t *sql)
 {
-    char *ret = sqlite3_mprintf(arg);
+    char *ret = sqlite3_mprintf("%q", arg);
     apr_pool_cleanup_register(pool, ret, (void *) sqlite3_free,
                               apr_pool_cleanup_null);
     return ret;

Modified: apr/apr-util/trunk/test/testdbd.c
URL: http://svn.apache.org/viewcvs/apr/apr-util/trunk/test/testdbd.c?rev=372724&r1=372723&r2=372724&view=diff
==============================================================================
--- apr/apr-util/trunk/test/testdbd.c (original)
+++ apr/apr-util/trunk/test/testdbd.c Thu Jan 26 20:28:25 2006
@@ -136,6 +136,14 @@
     ABTS_ASSERT(tc, "If we overseek, get_row should return -1", rv == -1);
 }
 
+static void test_escape(abts_case *tc, apr_dbd_t *handle,
+                        const apr_dbd_driver_t *driver)
+{
+  const char *escaped = apr_dbd_escape(driver, p, "foo'bar", handle);
+
+  ABTS_STR_EQUAL(tc, "foo''bar", escaped);
+}
+
 static void test_dbd_generic(abts_case *tc, apr_dbd_t* handle, 
                              const apr_dbd_driver_t* driver)
 {
@@ -155,6 +163,8 @@
     delete_rows(tc, handle, driver);
     select_rows(tc, handle, driver, 0);
     drop_table(tc, handle, driver);
+
+    test_escape(tc, handle, driver);
 
     rv = apr_dbd_close(driver, handle);
     ABTS_ASSERT(tc, "failed to close database", rv == APR_SUCCESS);



Mime
View raw message