File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -205,7 +205,11 @@ void php_filter_string(PHP_INPUT_FILTER_PARAM_DECL)
205
205
206
206
if (new_len == 0 ) {
207
207
zval_dtor (value );
208
- ZVAL_EMPTY_STRING (value );
208
+ if (flags & FILTER_FLAG_EMPTY_STRING_NULL ) {
209
+ ZVAL_NULL (value );
210
+ } else {
211
+ ZVAL_EMPTY_STRING (value );
212
+ }
209
213
return ;
210
214
}
211
215
}
@@ -280,6 +284,9 @@ void php_filter_unsafe_raw(PHP_INPUT_FILTER_PARAM_DECL)
280
284
}
281
285
282
286
php_filter_encode_html (value , enc );
287
+ } else if (flags & FILTER_FLAG_EMPTY_STRING_NULL && Z_STRLEN_P (value ) == 0 ) {
288
+ zval_dtor (value );
289
+ ZVAL_NULL (value );
283
290
}
284
291
}
285
292
/* }}} */
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #53037 (FILTER_FLAG_EMPTY_STRING_NULL is not implemented)
3
+ --SKIPIF--
4
+ <?php if (!extension_loaded ("filter " )) die ("skip " ); ?>
5
+ --FILE--
6
+ <?php
7
+ var_dump (
8
+ filter_var ("" , FILTER_DEFAULT ),
9
+ filter_var ("" , FILTER_DEFAULT , array ('flags ' => FILTER_FLAG_EMPTY_STRING_NULL ))
10
+ );
11
+ ?>
12
+ --EXPECT--
13
+ string(0) ""
14
+ NULL
You can’t perform that action at this time.
0 commit comments