xref: /PHP-5.4/ext/filter/tests/bug7586.phpt (revision 2c3db736)
1--TEST--
2input_get_args() filter not reseted between elements
3--SKIPIF--
4<?php if (!extension_loaded("filter")) die("skip"); ?>
5--FILE--
6<?php
7$data = array(
8    'product_id'    => 'libgd<script>',
9    'component'     => '10dhsajkkdhk <do>',
10    'versions'      => '2.0.33',
11    'testscalar'    => array('2','23','10','12'),
12    'testarray'     => '2',
13);
14
15$args = array(
16    'product_id'    => FILTER_SANITIZE_ENCODED,
17    'component'     => array('flags'    => FILTER_FORCE_ARRAY,
18                             'options'  => array("min_range"=>1, "max_range"=>10)
19                        ),
20    'versions'      => array(
21                            'filter' => FILTER_SANITIZE_ENCODED,
22                            'flags'  => FILTER_REQUIRE_SCALAR,
23                            ),
24    'doesnotexist'  => FILTER_VALIDATE_INT,
25    'testscalar'    => FILTER_VALIDATE_INT,
26    'testarray' => array(
27                            'filter' => FILTER_VALIDATE_INT,
28                            'flags'  => FILTER_FORCE_ARRAY,
29                        )
30
31);
32$out = filter_var_array($data, $args);
33var_dump($out);
34?>
35--EXPECTF--
36array(6) {
37  ["product_id"]=>
38  string(17) "libgd%3Cscript%3E"
39  ["component"]=>
40  array(1) {
41    [0]=>
42    string(17) "%s"
43  }
44  ["versions"]=>
45  string(6) "2.0.33"
46  ["doesnotexist"]=>
47  NULL
48  ["testscalar"]=>
49  bool(false)
50  ["testarray"]=>
51  array(1) {
52    [0]=>
53    int(2)
54  }
55}
56