diff options
| author | Ilia Alshanetsky <iliaa@php.net> | 2011-04-03 16:30:31 +0000 |
|---|---|---|
| committer | Ilia Alshanetsky <iliaa@php.net> | 2011-04-03 16:30:31 +0000 |
| commit | 063aba2e655139a32de8c17e03d860dd1763f3d1 (patch) | |
| tree | e60cce3c22d7f64a289bfc33b5894af1b2115c53 | |
| parent | 5a8c917c377281819cd14a5fbf9132d2ac11cbef (diff) | |
| download | php-git-063aba2e655139a32de8c17e03d860dd1763f3d1.tar.gz | |
Fixed bug #53037 (FILTER_FLAG_EMPTY_STRING_NULL is not implemented).
| -rw-r--r-- | ext/filter/sanitizing_filters.c | 9 | ||||
| -rw-r--r-- | ext/filter/tests/bug53037.phpt | 14 |
2 files changed, 22 insertions, 1 deletions
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-- +<?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 |
