]> granicus.if.org Git - php/commitdiff
MFH
authorMarcus Boerger <helly@php.net>
Fri, 22 Nov 2002 15:53:01 +0000 (15:53 +0000)
committerMarcus Boerger <helly@php.net>
Fri, 22 Nov 2002 15:53:01 +0000 (15:53 +0000)
ext/dba/dba.c
ext/dba/tests/dba008.phpt

index 23679c065c2830ed412eeb5414d22a103d5a4bac..c932e8affee9cbf481f2394877f74f8ccc5fde18 100644 (file)
@@ -285,6 +285,8 @@ static void php_dba_update(INTERNAL_FUNCTION_PARAMETERS, int mode)
 {
        DBA_ID_PARS;
        zval **val, **key;
+       char *v;
+       int len;
 
        if(ac != 3 || zend_get_parameters_ex(ac, &key, &val, &id) != SUCCESS) {
                WRONG_PARAM_COUNT;
@@ -295,8 +297,19 @@ static void php_dba_update(INTERNAL_FUNCTION_PARAMETERS, int mode)
 
        DBA_WRITE_CHECK;
        
-       if(info->hnd->update(info, VALLEN(key), VALLEN(val), mode TSRMLS_CC) == SUCCESS)
-               RETURN_TRUE;
+       if (PG(magic_quotes_runtime)) {
+               len = Z_STRLEN_PP(val);
+               v = estrndup(Z_STRVAL_PP(val), len);
+               php_stripslashes(v, &len TSRMLS_CC); 
+               if(info->hnd->update(info, VALLEN(key), v, len, mode TSRMLS_CC) == SUCCESS) {
+                       efree(v);
+                       RETURN_TRUE;
+               }
+               efree(v);
+       } else {
+               if(info->hnd->update(info, VALLEN(key), VALLEN(val), mode TSRMLS_CC) == SUCCESS)
+                       RETURN_TRUE;
+       }
        RETURN_FALSE;
 }
 /* }}} */
index 340131c30b6535b8de8e36a53f3cd91f0452a389..84a47ba0836f7c7b392420582fddac0f3c912ac1 100644 (file)
@@ -10,11 +10,15 @@ DBA magic_quotes_runtime Test
        require_once('test.inc');
        echo "database handler: $handler\n";
        if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
-               dba_insert("key1", '"', $db_file);
                ini_set('magic_quotes_runtime', 0);
+               dba_insert("key1", '"', $db_file);
                var_dump(dba_fetch("key1", $db_file));
                ini_set('magic_quotes_runtime', 1);
                var_dump(dba_fetch("key1", $db_file));
+               dba_replace("key1", '\"', $db_file);
+               var_dump(dba_fetch("key1", $db_file));
+               ini_set('magic_quotes_runtime', 0);
+               var_dump(dba_fetch("key1", $db_file));
                dba_close($db_file);
        } else {
                echo "Error creating database\n";
@@ -24,3 +28,5 @@ DBA magic_quotes_runtime Test
 database handler: %s
 string(1) """
 string(2) "\""
+string(2) "\""
+string(1) """