Bug #76366 [Ver->Csd]: References in sub-array for filtering breaks the filter
| From: | nikic@php.net | Date: | Sat, 07 Jul 2018 10:08:54 +0000 |
| Subject: | Bug #76366 [Ver->Csd]: References in sub-array for filtering breaks the filter | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-216196@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76366&edit=1
ID: 76366
Updated by: nikic@php.net
Reported by: dirk dot gerigk at atraveo dot com
Summary: References in sub-array for filtering breaks the
filter
-Status: Verified
+Status: Closed
Type: Bug
Package: Filter related
Operating System: Ubuntu
PHP Version: 7.0Git-2018-05-22 (snap)
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of gao_zihang@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=47fb17b108b401d8dbb5f1b94ec99ea0d020288a
Log: Fixed bug #76366 (references in sub-array for filtering breaks the filter)
Previous Comments:
------------------------------------------------------------------------
[2018-05-23 10:06:00] cmb@php.net
Confirmed: <https://3v4l.org/83gXR>
------------------------------------------------------------------------
[2018-05-22 14:03:51] dirk dot gerigk at atraveo dot com
Description:
------------
When using an array for filter variables and one sub-array is (or has) an reference the filter will
not filter.
This happens in all versions PHP >= 7. In PHP 5.6 it works correct.
It takes me a long time to figure out, that the reference in the array produces the wrong behavior.
If you var_dump $args before using it all seems fine.
Test script:
---------------
#array to filter
$data = ['foo' => 6];
#filter args
$args = ['foo'=> ['filter' => FILTER_VALIDATE_INT,'flags' =>
FILTER_FORCE_ARRAY]];
$args['foo']['options']=[];
#create reference
$options = &$args['foo']['options'];
#set options
$options['min_range']=1;
$options['max_range']=5;
#show the filter result
print_r(filter_var_array($data,$args));
Expected result:
----------------
Array ( [foo] => Array ( [0] => ) )
Actual result:
--------------
Array ( [foo] => Array ( [0] => 6 ) )
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76366&edit=1