From b406b3d6247db5b46154dac86d026a1da7a697aa Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 7 Jul 2020 08:57:05 +0200 Subject: [PATCH] Don't allow separation in callback filter 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 | 2 +- ext/filter/tests/029.phpt | 31 ++++++++----------------------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/ext/filter/callback_filter.c b/ext/filter/callback_filter.c index d02a30b754..edba63e562 100644 --- a/ext/filter/callback_filter.c +++ b/ext/filter/callback_filter.c @@ -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); diff --git a/ext/filter/tests/029.phpt b/ext/filter/tests/029.phpt index 2c5d64cbb2..fc191f1710 100644 --- a/ext/filter/tests/029.phpt +++ b/ext/filter/tests/029.phpt @@ -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 -- 2.50.1