From 47012ccd8f7f091d234693ed23e072da5e9a8328 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Sun, 3 Apr 2011 16:30:31 +0000 Subject: [PATCH] Fixed bug #53037 (FILTER_FLAG_EMPTY_STRING_NULL is not implemented). --- NEWS | 3 +++ ext/filter/sanitizing_filters.c | 9 ++++++++- ext/filter/tests/bug53037.phpt | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 ext/filter/tests/bug53037.phpt diff --git a/NEWS b/NEWS index 1ca5022ce72..534e075ae9e 100644 --- a/NEWS +++ b/NEWS @@ -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) diff --git a/ext/filter/sanitizing_filters.c b/ext/filter/sanitizing_filters.c index 56a5d72639b..c79c09b9176 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 00000000000..4a1e9e318b0 --- /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