]> granicus.if.org Git - php/commitdiff
Don't allow separation in callback filter
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 7 Jul 2020 06:57:05 +0000 (08:57 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 7 Jul 2020 06:57:05 +0000 (08:57 +0200)
This causes some tests to fail. Those tests are specifically about
the callback not being able to modify the data though, so this is
clearly not supposed to be a supported use-case.

ext/filter/callback_filter.c
ext/filter/tests/029.phpt

index d02a30b7544d579a252fba2759befd96c93498b7..edba63e5627dd764b37c13c2fc09929d4e8c0c15 100644 (file)
@@ -30,7 +30,7 @@ void php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL)
        }
 
        ZVAL_COPY(&args[0], value);
-       status = call_user_function_ex(NULL, NULL, option_array, &retval, 1, args, 0, NULL);
+       status = call_user_function(NULL, NULL, option_array, &retval, 1, args);
 
        if (status == SUCCESS && !Z_ISUNDEF(retval)) {
                zval_ptr_dtor(value);
index 2c5d64cbb23b663cacd408f45bd3ae12b3b74e39..fc191f1710aa09d7601c008967bc9dc500ea3b27 100644 (file)
@@ -45,30 +45,13 @@ var_dump(filter_var("data", FILTER_CALLBACK, array("options"=>"test2")));
 var_dump(filter_var("~!@#$%^&*()_QWERTYUIOPASDFGHJKLZXCVBNM<>>?\"}{:", FILTER_CALLBACK, array("options"=>"test2")));
 var_dump(filter_var("", FILTER_CALLBACK, array("options"=>"test2")));
 
-/* unsetting data */
-function test3(&$var) {
-    unset($var);
-}
-
-var_dump(filter_var("data", FILTER_CALLBACK, array("options"=>"test3")));
-var_dump(filter_var("~!@#$%^&*()_QWERTYUIOPASDFGHJKLZXCVBNM<>>?\"}{:", FILTER_CALLBACK, array("options"=>"test3")));
-var_dump(filter_var("", FILTER_CALLBACK, array("options"=>"test3")));
-
-/* unset data and return value */
-function test4(&$var) {
-    unset($var);
-    return 1;
-}
-
-var_dump(filter_var("data", FILTER_CALLBACK, array("options"=>"test4")));
-
 /* thrown exception in the callback */
-function test5(&$var) {
+function test3($var) {
     throw new Exception("test");
 }
 
 try {
-    var_dump(filter_var("data", FILTER_CALLBACK, array("options"=>"test5")));
+    var_dump(filter_var("data", FILTER_CALLBACK, array("options"=>"test3")));
 } catch (Exception $e) {
     var_dump($e->getMessage());
 }
@@ -94,12 +77,14 @@ string(0) ""
 NULL
 NULL
 NULL
+
+Warning: test2(): Argument #1 ($var) must be passed by reference, value given in %s on line %d
 NULL
+
+Warning: test2(): Argument #1 ($var) must be passed by reference, value given in %s on line %d
 NULL
+
+Warning: test2(): Argument #1 ($var) must be passed by reference, value given in %s on line %d
 NULL
-NULL
-NULL
-NULL
-int(1)
 string(4) "test"
 Done