summaryrefslogtreecommitdiff
path: root/ext/filter
diff options
context:
space:
mode:
Diffstat (limited to 'ext/filter')
-rw-r--r--ext/filter/callback_filter.c4
-rw-r--r--ext/filter/filter.c27
-rw-r--r--ext/filter/filter_private.h4
-rw-r--r--ext/filter/logical_filters.c6
-rw-r--r--ext/filter/php_filter.h4
-rw-r--r--ext/filter/sanitizing_filters.c4
-rw-r--r--ext/filter/tests/052.phpt73
-rw-r--r--ext/filter/tests/053.phpt15
-rw-r--r--ext/filter/tests/bug44445.phpt12
9 files changed, 125 insertions, 24 deletions
diff --git a/ext/filter/callback_filter.c b/ext/filter/callback_filter.c
index e72377e17..4405347d9 100644
--- a/ext/filter/callback_filter.c
+++ b/ext/filter/callback_filter.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2007 The PHP Group |
+ | Copyright (c) 1997-2008 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: callback_filter.c,v 1.9.2.4 2007/01/01 09:36:00 sebastian Exp $ */
+/* $Id: callback_filter.c,v 1.9.2.5 2007/12/31 07:20:06 sebastian Exp $ */
#include "php_filter.h"
diff --git a/ext/filter/filter.c b/ext/filter/filter.c
index ba6367d5c..e26a747f9 100644
--- a/ext/filter/filter.c
+++ b/ext/filter/filter.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2007 The PHP Group |
+ | Copyright (c) 1997-2008 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: filter.c,v 1.52.2.39 2007/04/04 20:50:26 pajoye Exp $ */
+/* $Id: filter.c,v 1.52.2.42 2008/02/24 18:34:30 felipe Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -275,7 +275,7 @@ PHP_MINFO_FUNCTION(filter)
{
php_info_print_table_start();
php_info_print_table_row( 2, "Input Validation and Filtering", "enabled" );
- php_info_print_table_row( 2, "Revision", "$Revision: 1.52.2.39 $");
+ php_info_print_table_row( 2, "Revision", "$Revision: 1.52.2.42 $");
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
@@ -322,7 +322,7 @@ static void php_zval_filter(zval **value, long filter, long flags, zval *options
filter_func.function(*value, flags, options, charset TSRMLS_CC);
if (
- options &&
+ options && (Z_TYPE_P(options) == IS_ARRAY || Z_TYPE_P(options) == IS_OBJECT) &&
((flags & FILTER_NULL_ON_FAILURE && Z_TYPE_PP(value) == IS_NULL) ||
(!(flags & FILTER_NULL_ON_FAILURE) && Z_TYPE_PP(value) == IS_BOOL && Z_LVAL_PP(value) == 0)) &&
zend_hash_exists(HASH_OF(options), "default", sizeof("default"))
@@ -453,15 +453,16 @@ static void php_zval_filter_recursive(zval **value, long filter, long flags, zva
for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(value), &pos);
zend_hash_get_current_data_ex(Z_ARRVAL_PP(value), (void **) &element, &pos) == SUCCESS;
- zend_hash_move_forward_ex(Z_ARRVAL_PP(value), &pos)) {
-
- if (Z_TYPE_PP(element) == IS_ARRAY) {
- Z_ARRVAL_PP(element)->nApplyCount++;
- php_zval_filter_recursive(element, filter, flags, options, charset, copy TSRMLS_CC);
- Z_ARRVAL_PP(element)->nApplyCount--;
- } else {
- php_zval_filter(element, filter, flags, options, charset, copy TSRMLS_CC);
- }
+ zend_hash_move_forward_ex(Z_ARRVAL_PP(value), &pos)
+ ) {
+ SEPARATE_ZVAL_IF_NOT_REF(element);
+ if (Z_TYPE_PP(element) == IS_ARRAY) {
+ Z_ARRVAL_PP(element)->nApplyCount++;
+ php_zval_filter_recursive(element, filter, flags, options, charset, copy TSRMLS_CC);
+ Z_ARRVAL_PP(element)->nApplyCount--;
+ } else {
+ php_zval_filter(element, filter, flags, options, charset, copy TSRMLS_CC);
+ }
}
} else {
php_zval_filter(value, filter, flags, options, charset, copy TSRMLS_CC);
diff --git a/ext/filter/filter_private.h b/ext/filter/filter_private.h
index 6ae79afb5..e8e8fcf3a 100644
--- a/ext/filter/filter_private.h
+++ b/ext/filter/filter_private.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2007 The PHP Group |
+ | Copyright (c) 1997-2008 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: filter_private.h,v 1.12.2.9 2007/01/01 09:36:00 sebastian Exp $ */
+/* $Id: filter_private.h,v 1.12.2.10 2007/12/31 07:20:06 sebastian Exp $ */
#ifndef FILTER_PRIVATE_H
#define FILTER_PRIVATE_H
diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c
index 4463f4e0d..103d5a51e 100644
--- a/ext/filter/logical_filters.c
+++ b/ext/filter/logical_filters.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2007 The PHP Group |
+ | Copyright (c) 1997-2008 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: logical_filters.c,v 1.1.2.22 2007/05/03 23:38:27 iliaa Exp $ */
+/* $Id: logical_filters.c,v 1.1.2.24 2008/03/18 23:32:42 iliaa Exp $ */
#include "php_filter.h"
#include "filter_private.h"
@@ -469,7 +469,7 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
{
/* From http://cvs.php.net/co.php/pear/HTML_QuickForm/QuickForm/Rule/Email.php?r=1.4 */
- const char regexp[] = "/^((\\\"[^\\\"\\f\\n\\r\\t\\b]+\\\")|([\\w\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+(\\.[\\w\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\\-])+\\.)+[A-Za-z\\-]+))$/D";
+ const char regexp[] = "/^((\\\"[^\\\"\\f\\n\\r\\t\\b]+\\\")|([\\w\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+(\\.[\\w\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]+)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9])(([A-Za-z0-9\\-])*([A-Za-z0-9]))?\\.)+[A-Za-z\\-]+))$/D";
pcre *re = NULL;
pcre_extra *pcre_extra = NULL;
diff --git a/ext/filter/php_filter.h b/ext/filter/php_filter.h
index f4b0133d7..a1dd54a3e 100644
--- a/ext/filter/php_filter.h
+++ b/ext/filter/php_filter.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2007 The PHP Group |
+ | Copyright (c) 1997-2008 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_filter.h,v 1.10.2.2 2007/01/01 09:36:00 sebastian Exp $ */
+/* $Id: php_filter.h,v 1.10.2.3 2007/12/31 07:20:06 sebastian Exp $ */
#ifndef PHP_FILTER_H
#define PHP_FILTER_H
diff --git a/ext/filter/sanitizing_filters.c b/ext/filter/sanitizing_filters.c
index 17f33c3a2..132ae86f7 100644
--- a/ext/filter/sanitizing_filters.c
+++ b/ext/filter/sanitizing_filters.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2007 The PHP Group |
+ | Copyright (c) 1997-2008 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: sanitizing_filters.c,v 1.11.2.9 2007/01/01 09:36:00 sebastian Exp $ */
+/* $Id: sanitizing_filters.c,v 1.11.2.10 2007/12/31 07:20:06 sebastian Exp $ */
#include "php_filter.h"
#include "filter_private.h"
diff --git a/ext/filter/tests/052.phpt b/ext/filter/tests/052.phpt
new file mode 100644
index 000000000..257613e9d
--- /dev/null
+++ b/ext/filter/tests/052.phpt
@@ -0,0 +1,73 @@
+--TEST--
+filter_var() / filter_var_array() and passed data integrity
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+function filter_cb($var)
+{
+ return 1;
+}
+
+$data = array ('bar' => array ('fu<script>bar', 'bar<script>fu') );
+var_dump(filter_var($data, FILTER_SANITIZE_STRING, FILTER_FORCE_ARRAY));
+var_dump($data);
+var_dump(filter_var($data, FILTER_CALLBACK, array('options' => 'filter_cb')));
+var_dump($data);
+var_dump(filter_var_array($data, array('bar' => array('filter' => FILTER_CALLBACK, 'options' => 'filter_cb'))));
+var_dump($data);
+--EXPECT--
+array(1) {
+ ["bar"]=>
+ array(2) {
+ [0]=>
+ string(5) "fubar"
+ [1]=>
+ string(5) "barfu"
+ }
+}
+array(1) {
+ ["bar"]=>
+ array(2) {
+ [0]=>
+ string(13) "fu<script>bar"
+ [1]=>
+ string(13) "bar<script>fu"
+ }
+}
+array(1) {
+ ["bar"]=>
+ array(2) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(1)
+ }
+}
+array(1) {
+ ["bar"]=>
+ array(2) {
+ [0]=>
+ string(13) "fu<script>bar"
+ [1]=>
+ string(13) "bar<script>fu"
+ }
+}
+array(1) {
+ ["bar"]=>
+ array(2) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(1)
+ }
+}
+array(1) {
+ ["bar"]=>
+ array(2) {
+ [0]=>
+ string(13) "fu<script>bar"
+ [1]=>
+ string(13) "bar<script>fu"
+ }
+}
diff --git a/ext/filter/tests/053.phpt b/ext/filter/tests/053.phpt
new file mode 100644
index 000000000..218f7fd01
--- /dev/null
+++ b/ext/filter/tests/053.phpt
@@ -0,0 +1,15 @@
+--TEST--
+filter_var() - using callback
+--FILE--
+<?php
+
+function filter_test($str) { return FALSE; }
+filter_var('durty/boy', FILTER_CALLBACK, array(
+ 'options' => 'filter_test',
+));
+
+print "Done\n";
+
+?>
+--EXPECTF--
+Done
diff --git a/ext/filter/tests/bug44445.phpt b/ext/filter/tests/bug44445.phpt
new file mode 100644
index 000000000..36a864141
--- /dev/null
+++ b/ext/filter/tests/bug44445.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #44445 (email validator does not handle domains starting/ending with a -)
+--SKIPIF--
+<?php if (!extension_loaded("filter")) die("skip"); ?>
+--FILE--
+<?php
+var_dump(filter_var("foo@-foo.com",FILTER_VALIDATE_EMAIL));
+var_dump(filter_var("foo@foo-.com",FILTER_VALIDATE_EMAIL));
+?>
+--EXPECT--
+bool(false)
+bool(false)