iliaa Sun Dec 3 21:27:36 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src NEWS
/php-src/ext/filter filter.c
Log:
Added "default" option that allows a default value to be set for an invalid
or missing value.
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.393&r2=1.2027.2.547.2.394&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.393 php-src/NEWS:1.2027.2.547.2.394
--- php-src/NEWS:1.2027.2.547.2.393 Sun Dec 3 17:13:11 2006
+++ php-src/NEWS Sun Dec 3 21:27:35 2006
@@ -42,6 +42,8 @@
. Make sure PHP_SELF is filtered in Apache 1 sapi.
. Fixed bug #39358 (INSTALL_HEADERS contains incorrect reference to
php_filter.h).
+ . Added "default" option that allows a default value to be set for
+ an invalid or missing value.
- Fixed wrong signature initialization in imagepng (Takeshi Abe)
- Added optimization for imageline with horizontal and vertial lines (Pierre)
- Fixed bug #39718 (possible crash if assert.callback is set in ini). (Ilia)
http://cvs.php.net/viewvc.cgi/php-src/ext/filter/filter.c?r1=1.52.2.28&r2=1.52.2.29&diff_format=u
Index: php-src/ext/filter/filter.c
diff -u php-src/ext/filter/filter.c:1.52.2.28
php-src/ext/filter/filter.c:1.52.2.29
--- php-src/ext/filter/filter.c:1.52.2.28 Mon Nov 13 19:32:58 2006
+++ php-src/ext/filter/filter.c Sun Dec 3 21:27:36 2006
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: filter.c,v 1.52.2.28 2006/11/13 19:32:58 tony2001 Exp $ */
+/* $Id: filter.c,v 1.52.2.29 2006/12/03 21:27:36 iliaa Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -275,7 +275,7 @@
{
php_info_print_table_start();
php_info_print_table_header( 2, "Input Validation and Filtering",
"enabled" );
- php_info_print_table_row( 2, "Revision", "$Revision: 1.52.2.28 $");
+ php_info_print_table_row( 2, "Revision", "$Revision: 1.52.2.29 $");
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
@@ -320,6 +320,19 @@
convert_to_string(*value);
filter_func.function(*value, flags, options, charset TSRMLS_CC);
+
+ if (
+ options &&
+ ((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"))
+ ) {
+ zval **tmp;
+ if (zend_hash_find(HASH_OF(options), "default",
sizeof("default"), (void **)&tmp) == SUCCESS) {
+ **value = **tmp;
+ zval_copy_ctor(*value);
+ }
+ }
}
/* }}} */
@@ -670,13 +683,20 @@
if (!input || !HASH_OF(input) || zend_hash_find(HASH_OF(input), var,
var_len + 1, (void **)&tmp) != SUCCESS) {
long filter_flags = 0;
- zval **option;
+ zval **option, **opt, **def;
if (filter_args) {
if (Z_TYPE_PP(filter_args) == IS_LONG) {
filter_flags = Z_LVAL_PP(filter_args);
} else if (Z_TYPE_PP(filter_args) == IS_ARRAY &&
zend_hash_find(HASH_OF(*filter_args), "flags", sizeof("flags"), (void
**)&option) == SUCCESS) {
convert_to_long(*option);
filter_flags = Z_LVAL_PP(option);
+ } else if (Z_TYPE_PP(filter_args) == IS_ARRAY &&
+ zend_hash_find(HASH_OF(*filter_args),
"options", sizeof("options"), (void **)&opt) == SUCCESS &&
+ zend_hash_find(HASH_OF(*opt), "default",
sizeof("default"), (void **)&def) == SUCCESS
+ ) {
+ *return_value = **def;
+ zval_copy_ctor(return_value);
+ return;
}
}
if (filter_flags & FILTER_NULL_ON_FAILURE) {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php