mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
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.
This commit is contained in:
parent
829a1e653a
commit
b406b3d624
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user