mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-8.3'
* PHP-8.3: Fix filter_var with callback and explicit REQUIRE_SCALAR
This commit is contained in:
commit
ddd2bd42ea
2 changed files with 26 additions and 8 deletions
|
@ -484,14 +484,6 @@ static void php_filter_call(
|
||||||
filter = zval_get_long(option);
|
filter = zval_get_long(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((option = zend_hash_str_find(filter_args_ht, "flags", sizeof("flags") - 1)) != NULL) {
|
|
||||||
filter_flags = zval_get_long(option);
|
|
||||||
|
|
||||||
if (!(filter_flags & FILTER_REQUIRE_ARRAY || filter_flags & FILTER_FORCE_ARRAY)) {
|
|
||||||
filter_flags |= FILTER_REQUIRE_SCALAR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((option = zend_hash_str_find_deref(filter_args_ht, "options", sizeof("options") - 1)) != NULL) {
|
if ((option = zend_hash_str_find_deref(filter_args_ht, "options", sizeof("options") - 1)) != NULL) {
|
||||||
if (filter != FILTER_CALLBACK) {
|
if (filter != FILTER_CALLBACK) {
|
||||||
if (Z_TYPE_P(option) == IS_ARRAY) {
|
if (Z_TYPE_P(option) == IS_ARRAY) {
|
||||||
|
@ -502,6 +494,14 @@ static void php_filter_call(
|
||||||
filter_flags = 0;
|
filter_flags = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((option = zend_hash_str_find(filter_args_ht, "flags", sizeof("flags") - 1)) != NULL) {
|
||||||
|
filter_flags = zval_get_long(option);
|
||||||
|
|
||||||
|
if (!(filter_flags & FILTER_REQUIRE_ARRAY || filter_flags & FILTER_FORCE_ARRAY)) {
|
||||||
|
filter_flags |= FILTER_REQUIRE_SCALAR;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Z_TYPE_P(filtered) == IS_ARRAY) {
|
if (Z_TYPE_P(filtered) == IS_ARRAY) {
|
||||||
|
|
18
ext/filter/tests/filter_callback_require_scalar.phpt
Normal file
18
ext/filter/tests/filter_callback_require_scalar.phpt
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
--TEST--
|
||||||
|
FILTER_CALLBACK with explicit FILTER_REQUIRE_SCALAR
|
||||||
|
--EXTENSIONS--
|
||||||
|
filter
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
function test($var) {
|
||||||
|
$callback = function ($var) {
|
||||||
|
return $var;
|
||||||
|
};
|
||||||
|
return filter_var($var, FILTER_CALLBACK, ['options' => $callback, 'flags' => FILTER_REQUIRE_SCALAR]);
|
||||||
|
}
|
||||||
|
var_dump(test('test'));
|
||||||
|
var_dump(test(['test']));
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
string(4) "test"
|
||||||
|
bool(false)
|
Loading…
Add table
Add a link
Reference in a new issue