]> granicus.if.org Git - php/commitdiff
- NULL is returned when a variable is not false, FALSE when the validation
authorPierre Joye <pajoye@php.net>
Sun, 14 May 2006 13:54:10 +0000 (13:54 +0000)
committerPierre Joye <pajoye@php.net>
Sun, 14 May 2006 13:54:10 +0000 (13:54 +0000)
  failed
- add tests for input_get_args

13 files changed:
ext/filter/filter.c
ext/filter/package.xml
ext/filter/package2.xml
ext/filter/tests/010.phpt
ext/filter/tests/013.phpt
ext/filter/tests/015.phpt
ext/filter/tests/016.phpt
ext/filter/tests/017.phpt
ext/filter/tests/018.phpt
ext/filter/tests/019.phpt
ext/filter/tests/030.phpt
ext/filter/tests/031.phpt
ext/filter/tests/032.phpt [new file with mode: 0644]

index 6e43727f1ab8977b5f8ddfc6ea62b9f7bf5175d8..7e8e6390ae66512941302335881f552744a9dc08 100644 (file)
@@ -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);
                }
index 9a0f45390c636c5b81b7786f2fe2aaaa0c9f8ee4..eeb1e0e9f39f93e6d07cb3f694e0b3e30e28e2bc 100644 (file)
@@ -24,19 +24,20 @@ of filters and mechanisms that users can use to safely access their input data.
  <license>PHP</license>
  <release>
   <state>beta</state>
-  <version>0.9.5</version>
-  <date>2006-05-01</date>
+  <version>0.10.0</version>
+  <date>2006-05-14</date>
   <notes>- 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
   </notes>
   <filelist>
index 1189e72fff9de88a664cfde87c88beca5955a523..0d881678e14d2c57f5b158b58f6ce66325612d13 100644 (file)
@@ -22,7 +22,7 @@ of filters and mechanisms that users can use to safely access their input data.
   <email>rasmus@php.net</email>
   <active>yes</active>
  </lead>
- <date>2006-01-23</date>
+ <date>2006-05-14</date>
  <time>10:04:15</time>
  <version>
   <release>0.10.0</release>
@@ -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
  </notes>
  <contents>
index d9c84ffe63040bc057f7dd86ec61aa344cf64c19..eaded25b65e87d796b6d1f8271d1cd98fe976008 100644 (file)
@@ -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) {
   }
index ac7cc5b3277753ad33e49d09558f7bd474f90f61..728a29c3218b0024f305449d4964abd9fd89286b 100644 (file)
@@ -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
index 18285c851297f3dd80684621784e556f23ba57a9..c46b7d1fb7a49709a30982e38602820ee4f64316 100644 (file)
@@ -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
index 727d404bd7e771a9da43b902784eb9d85a10d57f..5043567e8df6471012694710b880a0c6cc5eb66d 100644 (file)
@@ -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
index aee9433d7c994db7a22c527fcff77ee8d449ed28..18c323510c3787b5fad6db2511618463e81a2249 100644 (file)
@@ -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
index 184f2bb7e8f9b7d1fb865c4617e8576ef769359b..0f5c1a46edf0f0cfe50310f040810220a2cfd7cf 100644 (file)
@@ -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
index 7a2af50f774cfb4e8c1025c626ccc90379a2362d..7c22e104cc1f63da9158e547d0dc5b4f6af1a3b3 100644 (file)
@@ -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
index 4f4c702a2cb9240685ffcc37e5c30dd2ac71fac5..ff4ea3930bdc0c9dcda3823ea820bbde745328c6 100644 (file)
@@ -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";
        }
index 2ac2429d19953f60bffcd770762eedaaa71c3e20..a7432916122f33dc62495a4fe8d388ee3ea06e1e 100644 (file)
@@ -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 (file)
index 0000000..a7f8a7c
--- /dev/null
@@ -0,0 +1,55 @@
+--TEST--
+input_get_args()
+--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(//'filter' => FILTER_VALIDATE_INT,
+                             '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,
+                        )
+
+);
+
+$myinputs = input_get_args($args, INPUT_DATA, $data);
+var_dump($myinputs);
+?>
+--EXPECT--
+array(6) {
+  ["product_id"]=>
+  string(17) "libgd%3Cscript%3E"
+  ["component"]=>
+  array(1) {
+    [0]=>
+    string(17) "10dhsajkkdhk <do>"
+  }
+  ["versions"]=>
+  string(6) "2.0.33"
+  ["doesnotexist"]=>
+  NULL
+  ["testscalar"]=>
+  bool(false)
+  ["testarray"]=>
+  array(1) {
+    [0]=>
+    int(2)
+  }
+}