]> granicus.if.org Git - php/commitdiff
- implement FILTER_FLAG_ARRAY/SCALAR in input_get
authorPierre Joye <pajoye@php.net>
Thu, 31 Aug 2006 22:32:54 +0000 (22:32 +0000)
committerPierre Joye <pajoye@php.net>
Thu, 31 Aug 2006 22:32:54 +0000 (22:32 +0000)
- update changelog
- update tests

ext/filter/CREDITS
ext/filter/filter.c
ext/filter/filter_private.h
ext/filter/package.xml
ext/filter/package2.xml [deleted file]
ext/filter/tests/035.phpt

index fade411d07cdb3c210bf6cd12354a0ad6e894699..19cfe1d8db580cd6ff8c5bd8aac58b04ca574eb5 100644 (file)
@@ -1,2 +1,2 @@
 Input Filter
-Rasmus Lerdorf, Derick Rethans
+Rasmus Lerdorf, Derick Rethans, Pierre-Alain Joye
index 8e48602e28908eca96c909ebeb327a2a33ce840b..8dcc4d2818f534246c7b4776ea98beac810de53f 100644 (file)
@@ -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();
index 8c273e2e6063b4e82bbc1f5fe8430bce5da46aa2..74342a90df13eaf433e0ac071fa66c74b7894776 100644 (file)
@@ -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
index 45c38703df047f8760d5dc4bb7feaa742f4ada21..28ad122a5b44c1f99373b5ba6cc819533171a51e 100644 (file)
@@ -1,58 +1,71 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE package SYSTEM "../pear/package.dtd">
-<package>
+<?xml version="1.0" encoding="UTF-8"?>
+<package xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" packagerversion="1.4.6" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
   <name>filter</name>
+  <channel>pecl.php.net</channel>
   <summary>Extension for safely dealing with input parameters</summary>
-  <maintainers>
-    <maintainer>
-      <user>derick</user>
-      <name>Derick Rethans</name>
-      <email>derick@php.net</email>
-      <role>lead</role>
-    </maintainer>
-    <maintainer>
-      <user>rasmus</user>
-      <name>Rasmus Lerdorf</name>
-      <email>rasmus@php.net</email>
-      <role>lead</role>
-    </maintainer>
-  </maintainers>
-  <description>
-The Input Filter extension is meant to address this issue by implementing a set
+  <description>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.
  </description>
-  <license>PHP</license>
-  <release>
-    <state>beta</state>
-    <version>0.10.0</version>
-    <date>2006-05-14</date>
-    <notes>- Fixed PECL bug #8315, NULL character stops the validation (Pierre)
+  <lead>
+    <name>Pierre-Alain Joye</name>
+    <user>pajoye</user>
+    <email>pierre@php.net</email>
+    <active>yes</active>
+  </lead>
+  <lead>
+    <name>Derick Rethans</name>
+    <user>derick</user>
+    <email>derick@php.net</email>
+    <active>yes</active>
+  </lead>
+  <lead>
+    <name>Rasmus Lerdorf</name>
+    <user>rasmus</user>
+    <email>rasmus@php.net</email>
+    <active>yes</active>
+  </lead>
+  <date>2006-01-09</date>
+  <version>
+    <release>0.10.0</release>
+    <api>0.10.0</api>
+  </version>
+  <stability>
+    <release>beta</release>
+    <api>alpha</api>
+  </stability>
+  <license uri="http://www.php.net/license">PHP</license>
+  <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
 - 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)
+- 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)
-- 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)
+- 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
-  </notes>
-    <filelist>
-      <file role="src" name="config.m4"/>
-      <file role="src" name="config.w32"/>
-      <file role="src" name="filter.c"/>
-      <file role="src" name="filter_private.h"/>
-      <file role="src" name="callback_filter.c"/>
-      <file role="src" name="logical_filters.c"/>
-      <file role="src" name="sanitizing_filters.c"/>
-      <file role="src" name="php_filter.h"/>
-      <file role="doc" name="CREDITS"/>
+ </notes>
+  <contents>
+    <dir name="/">
+      <file name="callback_filter.c" role="src"/>
+      <file name="config.m4" role="src"/>
+      <file name="config.w32" role="src"/>
+      <file name="CREDITS" role="doc"/>
+      <file name="filter.c" role="src"/>
+      <file name="filter_private.h" role="src"/>
+      <file name="logical_filters.c" role="src"/>
+      <file name="php_filter.h" role="src"/>
+      <file name="sanitizing_filters.c" role="src"/>
       <dir name="tests">
         <file role="test" name="001.phpt"/>
         <file role="test" name="002.phpt"/>
@@ -88,12 +101,36 @@ of filters and mechanisms that users can use to safely access their input data.
         <file role="test" name="032.phpt"/>
         <file role="test" name="bug7586.phpt"/>
       </dir>
-    </filelist>
-    <deps>
-      <dep type="php" rel="ge" version="5.0.0"/>
-    </deps>
-  </release>
+    </dir>
+<!-- / -->
+  </contents>
+  <dependencies>
+    <required>
+      <php>
+        <min>5.0.0</min>
+      </php>
+      <pearinstaller>
+        <min>1.4.0b1</min>
+      </pearinstaller>
+    </required>
+  </dependencies>
+  <providesextension>filter</providesextension>
+  <extsrcrelease/>
+  <changelog>
+    <release>
+      <date>2006-01-23</date>
+      <time>10:04:15</time>
+      <version>
+        <release>0.9.4</release>
+        <api>0.9.4</api>
+      </version>
+      <stability>
+        <release>beta</release>
+        <api>beta</api>
+      </stability>
+      <notes>- 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</notes>
+    </release>
+  </changelog>
 </package>
-<!--
-vim:et:ts=1:sw=1
--->
diff --git a/ext/filter/package2.xml b/ext/filter/package2.xml
deleted file mode 100644 (file)
index ffe3d7d..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<package xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" packagerversion="1.4.6" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
-  <name>filter</name>
-  <channel>pecl.php.net</channel>
-  <summary>Extension for safely dealing with input parameters</summary>
-  <description>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.
- </description>
-  <lead>
-    <name>Derick Rethans</name>
-    <user>derick</user>
-    <email>derick@php.net</email>
-    <active>yes</active>
-  </lead>
-  <lead>
-    <name>Rasmus Lerdorf</name>
-    <user>rasmus</user>
-    <email>rasmus@php.net</email>
-    <active>yes</active>
-  </lead>
-  <date>2006-05-14</date>
-  <time>10:04:15</time>
-  <version>
-    <release>0.10.0</release>
-    <api>0.10.0</api>
-  </version>
-  <stability>
-    <release>beta</release>
-    <api>beta</api>
-  </stability>
-  <license uri="http://www.php.net/license">PHP</license>
-  <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
-- 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
- </notes>
-  <contents>
-    <dir name="/">
-      <file name="callback_filter.c" role="src"/>
-      <file name="config.m4" role="src"/>
-      <file name="config.w32" role="src"/>
-      <file name="CREDITS" role="doc"/>
-      <file name="filter.c" role="src"/>
-      <file name="filter_private.h" role="src"/>
-      <file name="logical_filters.c" role="src"/>
-      <file name="php_filter.h" role="src"/>
-      <file name="sanitizing_filters.c" role="src"/>
-      <dir name="tests">
-        <file role="test" name="001.phpt"/>
-        <file role="test" name="002.phpt"/>
-        <file role="test" name="003.phpt"/>
-        <file role="test" name="004.phpt"/>
-        <file role="test" name="005.phpt"/>
-        <file role="test" name="006.phpt"/>
-        <file role="test" name="007.phpt"/>
-        <file role="test" name="008.phpt"/>
-        <file role="test" name="009.phpt"/>
-        <file role="test" name="010.phpt"/>
-        <file role="test" name="011.phpt"/>
-        <file role="test" name="012.phpt"/>
-        <file role="test" name="013.phpt"/>
-        <file role="test" name="014.phpt"/>
-        <file role="test" name="015.phpt"/>
-        <file role="test" name="016.phpt"/>
-        <file role="test" name="017.phpt"/>
-        <file role="test" name="018.phpt"/>
-        <file role="test" name="019.phpt"/>
-        <file role="test" name="020.phpt"/>
-        <file role="test" name="021.phpt"/>
-        <file role="test" name="022.phpt"/>
-        <file role="test" name="023.phpt"/>
-        <file role="test" name="024.phpt"/>
-        <file role="test" name="025.phpt"/>
-        <file role="test" name="026.phpt"/>
-        <file role="test" name="027.phpt"/>
-        <file role="test" name="028.phpt"/>
-        <file role="test" name="029.phpt"/>
-        <file role="test" name="030.phpt"/>
-        <file role="test" name="031.phpt"/>
-        <file role="test" name="032.phpt"/>
-        <file role="test" name="bug7586.phpt"/>
-      </dir>
-    </dir>
-<!-- / -->
-  </contents>
-  <dependencies>
-    <required>
-      <php>
-        <min>5.0.0</min>
-      </php>
-      <pearinstaller>
-        <min>1.4.0b1</min>
-      </pearinstaller>
-    </required>
-  </dependencies>
-  <providesextension>filter</providesextension>
-  <extsrcrelease/>
-  <changelog>
-    <release>
-      <date>2006-01-23</date>
-      <time>10:04:15</time>
-      <version>
-        <release>0.9.4</release>
-        <api>0.9.4</api>
-      </version>
-      <stability>
-        <release>beta</release>
-        <api>beta</api>
-      </stability>
-      <notes>- 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</notes>
-    </release>
-  </changelog>
-</package>
index 054f43a6457d977a808f89d1dc406d28c6a5a62d..c73b8099af4908eb01391bc1561fd3234c830ab1 100644 (file)
@@ -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--