From 8e95777e47d20d73dba23bad909113e52039e7f7 Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Sun, 14 May 2006 13:54:10 +0000 Subject: [PATCH] - NULL is returned when a variable is not false, FALSE when the validation failed - add tests for input_get_args --- ext/filter/filter.c | 8 ++---- ext/filter/package.xml | 9 ++++--- ext/filter/package2.xml | 4 ++- ext/filter/tests/010.phpt | 8 +++--- ext/filter/tests/013.phpt | 16 ++++++------ ext/filter/tests/015.phpt | 12 ++++----- ext/filter/tests/016.phpt | 12 ++++----- ext/filter/tests/017.phpt | 8 +++--- ext/filter/tests/018.phpt | 20 +++++++------- ext/filter/tests/019.phpt | 8 +++--- ext/filter/tests/030.phpt | 2 +- ext/filter/tests/031.phpt | 6 ++--- ext/filter/tests/032.phpt | 55 +++++++++++++++++++++++++++++++++++++++ 13 files changed, 111 insertions(+), 57 deletions(-) create mode 100644 ext/filter/tests/032.phpt diff --git a/ext/filter/filter.c b/ext/filter/filter.c index 6e43727f1a..7e8e6390ae 100644 --- a/ext/filter/filter.c +++ b/ext/filter/filter.c @@ -616,7 +616,7 @@ PHP_FUNCTION(input_get) zval_copy_ctor(return_value); /* Watch out for empty strings */ php_zval_filter_recursive(return_value, filter, filter_flags, options, charset TSRMLS_CC); } else { - RETVAL_FALSE; + RETURN_NULL(); } } /* }}} */ @@ -759,11 +759,7 @@ PHP_FUNCTION(input_get_args) php_zval_filter(*tmp, filter, filter_flags, options, charset TSRMLS_CC); } - if (Z_TYPE_PP(tmp) == IS_NULL) { - add_assoc_bool(return_value, key, 0); - } else { - add_assoc_zval(return_value, key, *tmp); - } + add_assoc_zval(return_value, key, *tmp); } else { add_assoc_null(return_value, key); } diff --git a/ext/filter/package.xml b/ext/filter/package.xml index 9a0f45390c..eeb1e0e9f3 100644 --- a/ext/filter/package.xml +++ b/ext/filter/package.xml @@ -24,19 +24,20 @@ of filters and mechanisms that users can use to safely access their input data. PHP beta - 0.9.5 - 2006-05-01 + 0.10.0 + 2006-05-14 - 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 - Implemented PECL req #6641: negative values for hexadecimal and octal numbers are not supported. - Added support for php pcre expressions (Pierre) -- Fixed invalid error in pcre related validation (Pierre) -- Fixed possible leak in internal sapi_filter (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) +- input_get and input_get_args returns now FALSE when the validation failed + and NULL when the variable has not been found - Added JIT support diff --git a/ext/filter/package2.xml b/ext/filter/package2.xml index 1189e72fff..0d881678e1 100644 --- a/ext/filter/package2.xml +++ b/ext/filter/package2.xml @@ -22,7 +22,7 @@ of filters and mechanisms that users can use to safely access their input data. rasmus@php.net yes - 2006-01-23 + 2006-05-14 0.10.0 @@ -43,6 +43,8 @@ of filters and mechanisms that users can use to safely access their input data. - 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) +- input_get and input_get_args returns now FALSE when the validation failed + and NULL when the variable has not been found - Added JIT support diff --git a/ext/filter/tests/010.phpt b/ext/filter/tests/010.phpt index d9c84ffe63..eaded25b65 100644 --- a/ext/filter/tests/010.phpt +++ b/ext/filter/tests/010.phpt @@ -25,9 +25,9 @@ array(7) { [3]=> int(-23234) [4]=> - NULL + bool(false) [5]=> - NULL + bool(false) [6]=> array(0) { } @@ -42,9 +42,9 @@ array(7) { [3]=> float(-23234.123) [4]=> - NULL + bool(false) [5]=> - NULL + bool(false) [6]=> array(0) { } diff --git a/ext/filter/tests/013.phpt b/ext/filter/tests/013.phpt index ac7cc5b327..728a29c321 100644 --- a/ext/filter/tests/013.phpt +++ b/ext/filter/tests/013.phpt @@ -49,7 +49,7 @@ int(255) int(7) int(16711680) int(438) -NULL +bool(false) int(0) int(0) int(-255) @@ -60,13 +60,13 @@ int(-7) int(-16711680) int(-438) int(6) -NULL -NULL +bool(false) +bool(false) int(-1) int(0) -NULL -NULL -NULL -NULL -NULL +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) Done diff --git a/ext/filter/tests/015.phpt b/ext/filter/tests/015.phpt index 18285c8512..c46b7d1fb7 100644 --- a/ext/filter/tests/015.phpt +++ b/ext/filter/tests/015.phpt @@ -52,7 +52,7 @@ string(18) "file:///tmp/test.c" string(26) "ftp://ftp.example.com/tmp/" string(11) "/tmp/test.c" string(1) "/" -NULL +bool(false) string(6) "http:/" string(5) "http:" string(4) "http" @@ -60,13 +60,13 @@ string(0) "" string(2) "-1" array(0) { } -NULL +bool(false) string(10) "http://qwe" -NULL -NULL +bool(false) +bool(false) string(22) "http://www.example.com" -NULL +bool(false) string(42) "http://www.example.com/path/at/the/server/" -NULL +bool(false) string(40) "http://www.example.com/index.php?a=b&c=d" Done diff --git a/ext/filter/tests/016.phpt b/ext/filter/tests/016.phpt index 727d404bd7..5043567e8d 100644 --- a/ext/filter/tests/016.phpt +++ b/ext/filter/tests/016.phpt @@ -22,11 +22,11 @@ echo "Done\n"; --EXPECT-- string(5) "a@b.c" string(17) "abuse@example.com" -NULL -NULL -NULL -NULL -NULL -NULL +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) string(57) "QWERTYUIOPASDFGHJKLZXCVBNM@QWERTYUIOPASDFGHJKLZXCVBNM.NET" Done diff --git a/ext/filter/tests/017.phpt b/ext/filter/tests/017.phpt index aee9433d7c..18c323510c 100644 --- a/ext/filter/tests/017.phpt +++ b/ext/filter/tests/017.phpt @@ -14,11 +14,11 @@ echo "Done\n"; ?> --EXPECTF-- string(4) "data" -NULL +bool(false) string(4) "data" -NULL -NULL +bool(false) +bool(false) Warning: filter_data(): 'regexp' option missing in %s on line %d -NULL +bool(false) Done diff --git a/ext/filter/tests/018.phpt b/ext/filter/tests/018.phpt index 184f2bb7e8..0f5c1a46ed 100644 --- a/ext/filter/tests/018.phpt +++ b/ext/filter/tests/018.phpt @@ -27,24 +27,24 @@ echo "Done\n"; ?> --EXPECT-- string(11) "192.168.0.1" -NULL +bool(false) string(3) "::1" string(7) "fe00::0" -NULL -NULL +bool(false) +bool(false) string(9) "127.0.0.1" -NULL +bool(false) string(12) "192.0.34.166" string(9) "127.0.0.1" string(9) "192.0.0.1" string(12) "192.0.34.166" -NULL +bool(false) string(15) "255.255.255.255" -NULL -NULL -NULL -NULL -NULL +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) string(3) "::1" string(9) "127.0.0.1" Done diff --git a/ext/filter/tests/019.phpt b/ext/filter/tests/019.phpt index 7a2af50f77..7c22e104cc 100644 --- a/ext/filter/tests/019.phpt +++ b/ext/filter/tests/019.phpt @@ -12,9 +12,9 @@ var_dump(filter_data("1.1.1.1", FILTER_VALIDATE_IP)); echo "Done\n"; ?> --EXPECTF-- -NULL -NULL -NULL -NULL +bool(false) +bool(false) +bool(false) +bool(false) string(7) "1.1.1.1" Done diff --git a/ext/filter/tests/030.phpt b/ext/filter/tests/030.phpt index 4f4c702a2c..ff4ea3930b 100644 --- a/ext/filter/tests/030.phpt +++ b/ext/filter/tests/030.phpt @@ -23,7 +23,7 @@ $ipv6_test = array( ); foreach ($ipv6_test as $ip => $exp) { $out = filter_data($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6); - $out = (int) (is_null($out) ? 0 : 1); + $out = (int) ($out === false ? 0 : 1); if ($exp != $out) { echo "$ip failed\n"; } diff --git a/ext/filter/tests/031.phpt b/ext/filter/tests/031.phpt index 2ac2429d19..a743291612 100644 --- a/ext/filter/tests/031.phpt +++ b/ext/filter/tests/031.phpt @@ -45,10 +45,10 @@ float(7000) float(0.007) custom decimal: -NULL +bool(false) float(1.234) float(1.234) Warning: filter_data(): decimal separator must be one char in %s on line %d -NULL -NULL +bool(false) +bool(false) diff --git a/ext/filter/tests/032.phpt b/ext/filter/tests/032.phpt new file mode 100644 index 0000000000..a7f8a7c6cb --- /dev/null +++ b/ext/filter/tests/032.phpt @@ -0,0 +1,55 @@ +--TEST-- +input_get_args() +--FILE-- + 'libgd