helly Fri Nov 22 10:47:48 2002 EDT
Modified files:
/php4/ext/dba dba.c
/php4/ext/dba/tests dba008.phpt
Log:
Make magic_quotes_runtime work bidirectional for dba
Index: php4/ext/dba/dba.c
diff -u php4/ext/dba/dba.c:1.63 php4/ext/dba/dba.c:1.64
--- php4/ext/dba/dba.c:1.63 Thu Nov 14 16:09:40 2002
+++ php4/ext/dba/dba.c Fri Nov 22 10:47:47 2002
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba.c,v 1.63 2002/11/14 21:09:40 helly Exp $ */
+/* $Id: dba.c,v 1.64 2002/11/22 15:47:47 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -285,6 +285,8 @@
{
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 @@
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: php4/ext/dba/tests/dba008.phpt
diff -u php4/ext/dba/tests/dba008.phpt:1.2 php4/ext/dba/tests/dba008.phpt:1.3
--- php4/ext/dba/tests/dba008.phpt:1.2 Fri Nov 15 10:58:09 2002
+++ php4/ext/dba/tests/dba008.phpt Fri Nov 22 10:47:48 2002
@@ -10,11 +10,15 @@
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 @@
database handler: %s
string(1) """
string(2) "\""
+string(2) "\""
+string(1) """
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php