diff --git a/ext/filter/CREDITS b/ext/filter/CREDITS index fade411d07c..19cfe1d8db5 100644 --- a/ext/filter/CREDITS +++ b/ext/filter/CREDITS @@ -1,2 +1,2 @@ Input Filter -Rasmus Lerdorf, Derick Rethans +Rasmus Lerdorf, Derick Rethans, Pierre-Alain Joye diff --git a/ext/filter/filter.c b/ext/filter/filter.c index 8e48602e289..8dcc4d2818f 100644 --- a/ext/filter/filter.c +++ b/ext/filter/filter.c @@ -634,7 +634,29 @@ PHP_FUNCTION(input_get) } if (found) { + zval **option; + + if (options && filter_flags==0 && + zend_hash_find(HASH_OF(options), "flags", sizeof("flags"), (void **)&option) == SUCCESS) { + switch (Z_TYPE_PP(option)) { + case IS_ARRAY: + break; + default: + convert_to_long(*option); + filter_flags = Z_LVAL_PP(option); + break; + } + } else { + filter_flags = FILTER_FLAG_SCALAR; + } + zval_copy_ctor(return_value); /* Watch out for empty strings */ + + if (Z_TYPE_P(return_value) == IS_ARRAY && !(filter_flags & FILTER_FLAG_ARRAY)) { + zval_dtor(return_value); + ZVAL_BOOL(return_value, 0); + } + php_zval_filter_recursive(&return_value, filter, filter_flags, options, charset TSRMLS_CC); } else { RETURN_NULL(); diff --git a/ext/filter/filter_private.h b/ext/filter/filter_private.h index 8c273e2e606..74342a90df1 100644 --- a/ext/filter/filter_private.h +++ b/ext/filter/filter_private.h @@ -23,8 +23,8 @@ #define FILTER_FLAG_NONE 0x0000 -#define FILTER_FLAG_ARRAY 0x1000000 -#define FILTER_FLAG_SCALAR 0x2000000 +#define FILTER_FLAG_ARRAY 0x1000000 +#define FILTER_FLAG_SCALAR 0x2000000 #define FILTER_FLAG_ALLOW_OCTAL 0x0001 #define FILTER_FLAG_ALLOW_HEX 0x0002 diff --git a/ext/filter/package.xml b/ext/filter/package.xml index 45c38703df0..28ad122a5b4 100644 --- a/ext/filter/package.xml +++ b/ext/filter/package.xml @@ -1,58 +1,71 @@ - - - + + filter + pecl.php.net Extension for safely dealing with input parameters - - - derick - Derick Rethans - derick@php.net - lead - - - rasmus - Rasmus Lerdorf - rasmus@php.net - lead - - - -The Input Filter extension is meant to address this issue by implementing a set + The Input Filter extension is meant to address this issue by implementing a set of filters and mechanisms that users can use to safely access their input data. + - PHP - - beta - 0.10.0 - 2006-05-14 - - Fixed PECL bug #8315, NULL character stops the validation (Pierre) + + Pierre-Alain Joye + pajoye + pierre@php.net + yes + + + Derick Rethans + derick + derick@php.net + yes + + + Rasmus Lerdorf + rasmus + rasmus@php.net + yes + + 2006-01-09 + + 0.10.0 + 0.10.0 + + + beta + alpha + + PHP + - Fixed PECL bug #6136, ini_set should not be able to change the filter.default (Pierre) +- Fixed PECL bug #6639: uppercase hexadecimal digits are not supported - Fixed PECL bug #7733, Float exponential weird result (Pierre) - Fixed PECL bug #7715, Input_get float error (Pierre) -- Fixed PECL bug #6639: uppercase hexadecimal digits are not supported -- Fixed PECL bug #6136, ini_set should not be able to change the filter.default (Pierre) -- Implemented PECL req #6641: negative values for hexadecimal and octal numbers are not supported. -- Added support for php pcre expressions (Pierre) +- Fixed PECL bug #8316, empty string with FILTER_VALIDATE_INT returns 0 - Fixed Possible leak in internal sapi_filter (Pierre) +- Fixed an issue with multiple calls using the same input type (Tony) +- Fixed leak in sapi filter (Tony, Ilia) +- Fixed magic_quotes_gpc from being applied when RAW filter is used (Ilia) +- Implemented PECL req #6641: negative values for hexadecimal and octal numbers are not supported. +- Added support for custom decimal separator (Pierre) +- Added support for php pcre expressions (Pierre) - Added input_get_args, fetches all input in one call (Pierre) -- Added FILTER_FLAG_SCALAR and FILTER_FLAG_ARRAY , allows or not array values (Pierre) +- Added FILTER_FLAG_SCALAR and FILTER_FLAG_ARRAY, allows or not array values (Pierre) - Basic IPv6 (no option yet, only the syntax is verified) (Pierre) -- Add support for custom decimal separator (Pierre) -- INT and Float filters trim the values before the validations (spaces only) (Pierre) +- INT, Float and boolean filters trim the values before the validations (default trim()) (Pierre) - input_get and input_get_args returns now FALSE when the validation failed and NULL when the variable has not been found (Pierre) - Added JIT support - - - - - - - - - - - + + + + + + + + + + + + @@ -88,12 +101,36 @@ of filters and mechanisms that users can use to safely access their input data. - - - - - + + + + + + + 5.0.0 + + + 1.4.0b1 + + + + filter + + + + 2006-01-23 + + + 0.9.4 + 0.9.4 + + + beta + beta + + - Reimplement php_filter_callback() as exception-safe and without memleaks +- Renamed all constants. +- Fixed PECL bug #6124: Crash on HTML tags when using FS_STRING + + - diff --git a/ext/filter/package2.xml b/ext/filter/package2.xml deleted file mode 100644 index ffe3d7db444..00000000000 --- a/ext/filter/package2.xml +++ /dev/null @@ -1,127 +0,0 @@ - - - filter - pecl.php.net - Extension for safely dealing with input parameters - The Input Filter extension is meant to address this issue by implementing a set -of filters and mechanisms that users can use to safely access their input data. - - - - Derick Rethans - derick - derick@php.net - yes - - - Rasmus Lerdorf - rasmus - rasmus@php.net - yes - - 2006-05-14 - - - 0.10.0 - 0.10.0 - - - beta - beta - - PHP - - Fixed PECL bug #6136, ini_set should not be able to change the filter.default (Pierre) -- Fixed PECL bug #6639: uppercase hexadecimal digits are not supported -- Fixed PECL bug #7733, Float exponential weird result (Pierre) -- Fixed PECL bug #7715, Input_get float error (Pierre) -- Implemented PECL req #6641: negative values for hexadecimal and octal numbers are not supported. -- Added support for php pcre expressions (Pierre) -- Fixed Possible leak in internal sapi_filter (Pierre) -- Added input_get_args, fetches all input in one call (Pierre) -- Added FILTER_FLAG_SCALAR and FILTER_FLAG_ARRAY , allows or not array values (Pierre) -- Basic IPv6 (no option yet, only the syntax is verified) (Pierre) -- Add support for custom decimal separator (Pierre) -- INT and Float filters trim the values before the validations (spaces only) (Pierre) -- input_get and input_get_args returns now FALSE when the validation failed - and NULL when the variable has not been found (Pierre) -- Added JIT support - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5.0.0 - - - 1.4.0b1 - - - - filter - - - - 2006-01-23 - - - 0.9.4 - 0.9.4 - - - beta - beta - - - Reimplement php_filter_callback() as exception-safe and without memleaks -- Renamed all constants. -- Fixed PECL bug #6124: Crash on HTML tags when using FS_STRING - - - diff --git a/ext/filter/tests/035.phpt b/ext/filter/tests/035.phpt index 054f43a6457..c73b8099af4 100644 --- a/ext/filter/tests/035.phpt +++ b/ext/filter/tests/035.phpt @@ -12,10 +12,10 @@ var_dump($ret); $ret = input_get(INPUT_GET, 'a', FILTER_VALIDATE_INT, array('flags'=>FILTER_FLAG_ALLOW_OCTAL)); var_dump($ret); -$ret = input_get(INPUT_GET, 'ar', FILTER_VALIDATE_INT); +$ret = input_get(INPUT_GET, 'ar', FILTER_VALIDATE_INT, array('flags'=>FILTER_FLAG_ARRAY)); var_dump($ret); -$ret = input_get(INPUT_GET, 'ar', FILTER_VALIDATE_INT, array('flags'=>FILTER_FLAG_ALLOW_OCTAL)); +$ret = input_get(INPUT_GET, 'ar', FILTER_VALIDATE_INT, array('flags'=>FILTER_FLAG_ALLOW_OCTAL|FILTER_FLAG_ARRAY)); var_dump($ret); ?> --EXPECT--