[php-src] master: filter_input_array - Implement solution 2 of GH-13805 (#13804)
| From: | Juan Morales via GitHub | Date: | Sat, 06 Apr 2024 22:18:17 +0000 |
| Subject: | [php-src] master: filter_input_array - Implement solution 2 of GH-13805 (#13804) | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-127957@lists.php.net to get a copy of this message | ||
Author: Juan Morales (juan-morales)
Committer: GitHub (web-flow)
Pusher: nielsdos
Date: 2024-04-07T00:18:12+02:00
Commit: https://github.com/php/php-src/commit/c96b975f67f3f4d84aa3f33540e1530a9a786be1
Raw diff: https://github.com/php/php-src/commit/c96b975f67f3f4d84aa3f33540e1530a9a786be1.diff
filter_input_array - Implement solution 2 of GH-13805 (#13804)
Changed paths:
A ext/filter/tests/filter_input_array_001.phpt
M ext/filter/filter.c
Diff:
diff --git a/ext/filter/filter.c b/ext/filter/filter.c
index b787ef706c4f2..ee8db5ef3583b 100644
--- a/ext/filter/filter.c
+++ b/ext/filter/filter.c
@@ -690,29 +690,13 @@ PHP_FUNCTION(filter_input_array)
}
array_input = php_filter_get_storage(fetch_from);
+
if (EG(exception)) {
RETURN_THROWS();
}
if (!array_input) {
- zend_long filter_flags = 0;
- zval *option;
- if (op_long) {
- filter_flags = op_long;
- } else if (op_ht && (option = zend_hash_str_find(op_ht, "flags",
sizeof("flags") - 1)) != NULL) {
- filter_flags = zval_get_long(option);
- }
-
- /* The FILTER_NULL_ON_FAILURE flag inverts the usual return values of
- * the function: normally when validation fails false is returned, and
- * when the input value doesn't exist NULL is returned. With the flag
- * set, NULL and false should be returned, respectively. Ergo, although
- * the code below looks incorrect, it's actually right. */
- if (filter_flags & FILTER_NULL_ON_FAILURE) {
- RETURN_FALSE;
- } else {
- RETURN_NULL();
- }
+ RETURN_NULL();
}
php_filter_array_handler(array_input, op_ht, op_long, return_value, add_empty);
diff --git a/ext/filter/tests/filter_input_array_001.phpt
b/ext/filter/tests/filter_input_array_001.phpt
new file mode 100644
index 0000000000000..038ebc6dd2cdf
--- /dev/null
+++ b/ext/filter/tests/filter_input_array_001.phpt
@@ -0,0 +1,16 @@
+--TEST--
+filter_input_array: test FILTER_NULL_ON_FAILURE option does not affect general result on empty
input
+--EXTENSIONS--
+filter
+--FILE--
+<?php
+$args = [
+ "c" => [
+ "flags" => FILTER_NULL_ON_FAILURE,
+ ]
+];
+
+var_dump(filter_input_array(INPUT_GET, $args, true));
+?>
+--EXPECT--
+NULL