mirror of
https://github.com/php/php-src.git
synced 2025-08-19 17:04:47 +02:00
- #7586 (pecl), filter is not reseted between element
This commit is contained in:
parent
fd2199bf53
commit
1a0f27a707
2 changed files with 65 additions and 3 deletions
|
@ -495,7 +495,7 @@ PHP_FUNCTION(input_get)
|
||||||
zval *array_ptr = NULL, *array_ptr2 = NULL, *array_ptr3 = NULL;
|
zval *array_ptr = NULL, *array_ptr2 = NULL, *array_ptr3 = NULL;
|
||||||
HashTable *hash_ptr;
|
HashTable *hash_ptr;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
int filter_flags = 0;
|
long filter_flags = 0;
|
||||||
zval *options = NULL;
|
zval *options = NULL;
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls|lzs", &arg, &var, &var_len, &filter, &flags, &charset, &charset_len) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls|lzs", &arg, &var, &var_len, &filter, &flags, &charset, &charset_len) == FAILURE) {
|
||||||
|
@ -694,6 +694,14 @@ PHP_FUNCTION(input_get_args)
|
||||||
if (Z_TYPE_PP(element) != IS_ARRAY) {
|
if (Z_TYPE_PP(element) != IS_ARRAY) {
|
||||||
convert_to_long(*element);
|
convert_to_long(*element);
|
||||||
filter = Z_LVAL_PP(element);
|
filter = Z_LVAL_PP(element);
|
||||||
|
filter_flags = FILTER_FLAG_SCALAR;
|
||||||
|
|
||||||
|
if ((filter_flags & FILTER_FLAG_SCALAR) && Z_TYPE_PP(tmp) == IS_ARRAY) {
|
||||||
|
/* asked for scalar and found an array do not test further */
|
||||||
|
add_assoc_bool(return_value, key, 0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (zend_hash_find(HASH_OF(*element), "filter", sizeof("filter"), (void **)&option) == SUCCESS) {
|
if (zend_hash_find(HASH_OF(*element), "filter", sizeof("filter"), (void **)&option) == SUCCESS) {
|
||||||
convert_to_long(*option);
|
convert_to_long(*option);
|
||||||
|
@ -722,7 +730,7 @@ PHP_FUNCTION(input_get_args)
|
||||||
filter_flags = FILTER_FLAG_SCALAR;
|
filter_flags = FILTER_FLAG_SCALAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter_flags & FILTER_FLAG_SCALAR && Z_TYPE_PP(tmp) == IS_ARRAY) {
|
if ((filter_flags & FILTER_FLAG_SCALAR) && Z_TYPE_PP(tmp) == IS_ARRAY) {
|
||||||
/* asked for scalar and found an array do not test further */
|
/* asked for scalar and found an array do not test further */
|
||||||
add_assoc_bool(return_value, key, 0);
|
add_assoc_bool(return_value, key, 0);
|
||||||
continue;
|
continue;
|
||||||
|
@ -756,7 +764,8 @@ PHP_FUNCTION(input_get_args)
|
||||||
} else {
|
} else {
|
||||||
add_assoc_null(return_value, key);
|
add_assoc_null(return_value, key);
|
||||||
}
|
}
|
||||||
filter_flags = 0;
|
filter = FILTER_DEFAULT;
|
||||||
|
filter_flags = FILTER_FLAG_SCALAR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
53
ext/filter/tests/bug7586.phpt
Normal file
53
ext/filter/tests/bug7586.phpt
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
--TEST--
|
||||||
|
input_get_args() filter not reseted between elements
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$data = array(
|
||||||
|
'product_id' => 'libgd<script>',
|
||||||
|
'component' => '10dhsajkkdhk <do>',
|
||||||
|
'versions' => '2.0.33',
|
||||||
|
'testscalar' => array('2','23','10','12'),
|
||||||
|
'testarray' => '2',
|
||||||
|
);
|
||||||
|
|
||||||
|
$args = array(
|
||||||
|
'product_id' => FILTER_SANITIZE_ENCODED,
|
||||||
|
'component' => array('flags' => FILTER_FLAG_ARRAY,
|
||||||
|
'options' => array("min_range"=>1, "max_range"=>10)
|
||||||
|
),
|
||||||
|
'versions' => array(
|
||||||
|
'filter' => FILTER_SANITIZE_ENCODED,
|
||||||
|
'flags' => FILTER_FLAG_SCALAR,
|
||||||
|
),
|
||||||
|
'doesnotexist' => FILTER_VALIDATE_INT,
|
||||||
|
'testscalar' => FILTER_VALIDATE_INT,
|
||||||
|
'testarray' => array(
|
||||||
|
'filter' => FILTER_VALIDATE_INT,
|
||||||
|
'flags' => FILTER_FLAG_ARRAY,
|
||||||
|
)
|
||||||
|
|
||||||
|
);
|
||||||
|
$out = input_get_args($args, INPUT_DATA, $data);
|
||||||
|
var_dump($out);
|
||||||
|
?>
|
||||||
|
--EXPECTF--
|
||||||
|
array(6) {
|
||||||
|
["product_id"]=>
|
||||||
|
string(17) "libgd%3Cscript%3E"
|
||||||
|
["component"]=>
|
||||||
|
array(1) {
|
||||||
|
[0]=>
|
||||||
|
string(17) "%s"
|
||||||
|
}
|
||||||
|
["versions"]=>
|
||||||
|
string(6) "2.0.33"
|
||||||
|
["doesnotexist"]=>
|
||||||
|
NULL
|
||||||
|
["testscalar"]=>
|
||||||
|
bool(false)
|
||||||
|
["testarray"]=>
|
||||||
|
array(1) {
|
||||||
|
[0]=>
|
||||||
|
int(2)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue