On 12.09.2006 16:57, Derick Rethans wrote:
On Thu, 31 Aug 2006, Antony Dovgal wrote:

tony2001                Thu Aug 31 22:11:35 2006 UTC

Modified files: /php-src/ext/filter filter.c Log:
  change filters to operate on the copy of data, so multiple filters an be 
applied one after another

It was this patch that broke the default filter for the request parameters. Didn't manage to figure out yet how to best fix it though.

Please test the patch in attachment (you can also get it here: 
http://tony2001.phpclub.net/dev/tmp/filter.diff).
If there are no objections, I'll commit it soon.

--
Wbr, Antony Dovgal
Index: ext/filter/filter.c
===================================================================
RCS file: /repository/php-src/ext/filter/filter.c,v
retrieving revision 1.52.2.15
diff -u -p -d -r1.52.2.15 filter.c
--- ext/filter/filter.c 12 Sep 2006 16:10:33 -0000      1.52.2.15
+++ ext/filter/filter.c 14 Sep 2006 10:25:21 -0000
@@ -301,7 +301,7 @@ static filter_list_entry php_find_filter
 }
 /* }}} */
 
-static void php_zval_filter(zval **value, long filter, long flags, zval 
*options, char* charset TSRMLS_DC) /* {{{ */
+static void php_zval_filter(zval **value, long filter, long flags, zval 
*options, char* charset, zend_bool copy TSRMLS_DC) /* {{{ */
 {
        filter_list_entry  filter_func;
 
@@ -312,7 +312,9 @@ static void php_zval_filter(zval **value
                filter_func = php_find_filter(FILTER_DEFAULT);
        }
 
-       /* Comment this out until there is a better solution: 
SEPARATE_ZVAL(value); */
+       if (copy) {
+               SEPARATE_ZVAL(value);
+       }
        /* Here be strings */
        convert_to_string(*value);
 
@@ -379,7 +381,7 @@ static unsigned int php_sapi_filter(int 
                if (!(IF_G(default_filter) == FILTER_UNSAFE_RAW)) {
                        zval *tmp_new_var = &new_var;
                        Z_STRVAL(new_var) = estrndup(*val, val_len);
-                       php_zval_filter(&tmp_new_var, IF_G(default_filter), 
IF_G(default_filter_flags), NULL, NULL/*charset*/ TSRMLS_CC);
+                       php_zval_filter(&tmp_new_var, IF_G(default_filter), 
IF_G(default_filter_flags), NULL, NULL/*charset*/, 0 TSRMLS_CC);
                } else if (PG(magic_quotes_gpc)) {
                        Z_STRVAL(new_var) = php_addslashes(*val, 
Z_STRLEN(new_var), &Z_STRLEN(new_var), 0 TSRMLS_CC);
                } else {
@@ -413,7 +415,7 @@ static unsigned int php_sapi_filter(int 
 }
 /* }}} */
 
-static void php_zval_filter_recursive(zval **value, long filter, long flags, 
zval *options, char *charset TSRMLS_DC) /* {{{ */
+static void php_zval_filter_recursive(zval **value, long filter, long flags, 
zval *options, char *charset, zend_bool copy TSRMLS_DC) /* {{{ */
 {
        zval **element;
        HashPosition pos;
@@ -422,10 +424,10 @@ static void php_zval_filter_recursive(zv
                for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(value), 
&pos);
                         zend_hash_get_current_data_ex(Z_ARRVAL_PP(value), 
(void **) &element, &pos) == SUCCESS;
                         zend_hash_move_forward_ex(Z_ARRVAL_PP(value), &pos)) {
-                               php_zval_filter_recursive(element, filter, 
flags, options, charset TSRMLS_CC);
+                               php_zval_filter_recursive(element, filter, 
flags, options, charset, copy TSRMLS_CC);
                }
        } else {
-               php_zval_filter(value, filter, flags, options, charset 
TSRMLS_CC);
+               php_zval_filter(value, filter, flags, options, charset, copy 
TSRMLS_CC);
        }
 }
 /* }}} */
@@ -644,7 +646,7 @@ PHP_FUNCTION(input_get)
                        ZVAL_BOOL(return_value, 0);
                }
 
-               php_zval_filter_recursive(&return_value, filter, filter_flags, 
options, charset TSRMLS_CC);
+               php_zval_filter_recursive(&return_value, filter, filter_flags, 
options, charset, 1 TSRMLS_CC);
        } else {
                RETURN_NULL();
        }
@@ -673,6 +675,7 @@ PHP_FUNCTION(input_get_args)
        char *key;
        unsigned int key_len;
        unsigned long index;
+       zend_bool copy = 0;
 
        /* pointers to the zval array GET, POST,... */
        zval       *array_ptr = NULL;
@@ -700,6 +703,7 @@ PHP_FUNCTION(input_get_args)
 
                case PARSE_DATA:
                        array_ptr = values;
+                       copy = 1;
                        break;
 
                case PARSE_SESSION:
@@ -791,7 +795,7 @@ PHP_FUNCTION(input_get_args)
                        }
 
                        if (filter_flags & FILTER_FLAG_ARRAY) {
-                               php_zval_filter_recursive(tmp, filter, 
filter_flags, options, charset TSRMLS_CC);
+                               php_zval_filter_recursive(tmp, filter, 
filter_flags, options, charset, copy TSRMLS_CC);
 
                                /* ARRAY always returns an array */
                                if (Z_TYPE_PP(tmp) != IS_ARRAY) {
@@ -801,7 +805,7 @@ PHP_FUNCTION(input_get_args)
                                        *tmp = temparray;
                                }
                        } else {
-                               php_zval_filter(tmp, filter, filter_flags, 
options, charset TSRMLS_CC);
+                               php_zval_filter(tmp, filter, filter_flags, 
options, charset, copy TSRMLS_CC);
                        }
                        zval_add_ref(tmp);
                        add_assoc_zval(return_value, key, *tmp);
@@ -895,7 +899,7 @@ PHP_FUNCTION(filter_data)
                        }
                }
        }
-       php_zval_filter_recursive(&var, filter, filter_flags, options, charset 
TSRMLS_CC);
+       php_zval_filter_recursive(&var, filter, filter_flags, options, charset, 
1 TSRMLS_CC);
        RETURN_ZVAL(var, 1, 0);
 }
 /* }}} */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to