Fixed bug #53037 (FILTER_FLAG_EMPTY_STRING_NULL is not implemented).

This commit is contained in:
Ilia Alshanetsky 2011-04-03 16:30:31 +00:00
parent 4919f3286b
commit 47012ccd8f
3 changed files with 25 additions and 1 deletions

3
NEWS
View File

@ -28,6 +28,9 @@ PHP NEWS
- DBA extension:
. Fixed bug #54242 (dba_insert returns true if key already exists). (Felipe)
- Filter extension:
. Fixed bug #53037 (FILTER_FLAG_EMPTY_STRING_NULL is not implemented). (Ilia)
- LDAP extension:
. Fixed bug #53339 (Fails to build when compilng with gcc 4.5 and DSO
libraries). (Clint Byrum, Raphael)

View File

@ -205,7 +205,11 @@ void php_filter_string(PHP_INPUT_FILTER_PARAM_DECL)
if (new_len == 0) {
zval_dtor(value);
ZVAL_EMPTY_STRING(value);
if (flags & FILTER_FLAG_EMPTY_STRING_NULL) {
ZVAL_NULL(value);
} else {
ZVAL_EMPTY_STRING(value);
}
return;
}
}
@ -280,6 +284,9 @@ void php_filter_unsafe_raw(PHP_INPUT_FILTER_PARAM_DECL)
}
php_filter_encode_html(value, enc);
} else if (flags & FILTER_FLAG_EMPTY_STRING_NULL && Z_STRLEN_P(value) == 0) {
zval_dtor(value);
ZVAL_NULL(value);
}
}
/* }}} */

View File

@ -0,0 +1,14 @@
--TEST--
Bug #53037 (FILTER_FLAG_EMPTY_STRING_NULL is not implemented)
--SKIPIF--
<?php if (!extension_loaded("filter")) die("skip"); ?>
--FILE--
<?php
var_dump(
filter_var("", FILTER_DEFAULT),
filter_var("", FILTER_DEFAULT, array('flags' => FILTER_FLAG_EMPTY_STRING_NULL))
);
?>
--EXPECT--
string(0) ""
NULL