From: Ilia Alshanetsky Date: Sun, 3 Apr 2011 16:30:31 +0000 (+0000) Subject: Fixed bug #53037 (FILTER_FLAG_EMPTY_STRING_NULL is not implemented). X-Git-Tag: php-5.4.0alpha1~191^2~86 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=063aba2e655139a32de8c17e03d860dd1763f3d1;p=php Fixed bug #53037 (FILTER_FLAG_EMPTY_STRING_NULL is not implemented). --- diff --git a/ext/filter/sanitizing_filters.c b/ext/filter/sanitizing_filters.c index 7b7c5fe4ae..b0348dbef5 100644 --- a/ext/filter/sanitizing_filters.c +++ b/ext/filter/sanitizing_filters.c @@ -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); } } /* }}} */ diff --git a/ext/filter/tests/bug53037.phpt b/ext/filter/tests/bug53037.phpt new file mode 100644 index 0000000000..4a1e9e318b --- /dev/null +++ b/ext/filter/tests/bug53037.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #53037 (FILTER_FLAG_EMPTY_STRING_NULL is not implemented) +--SKIPIF-- + +--FILE-- + FILTER_FLAG_EMPTY_STRING_NULL)) +); +?> +--EXPECT-- +string(0) "" +NULL