Skip to content

Commit 40807be

Browse files
committed
Deprecate filter.default
There's a subtlety here regarding filter.default_flags. The RFC stated that no separate deprecation warning will be emitted for it, on the premise that it is only meaningful if filter.default is set. However, it turns out that even FILTER_UNSAFE_RAW (which is the "no-op filter") can be combined with stripping flags. However, this is compensated by the fact that this doesn't actually work when setting filter.default=unsafe_raw and non-default filter.default_flags -- the flags are simply ignored in that case. So everything works out in the end. Part of https://wiki.php.net/rfc/deprecations_php_8_1.
1 parent 1fe63bf commit 40807be

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

ext/filter/filter.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ static PHP_INI_MH(UpdateDefaultFilter) /* {{{ */
107107
for (i = 0; i < size; ++i) {
108108
if ((strcasecmp(ZSTR_VAL(new_value), filter_list[i].name) == 0)) {
109109
IF_G(default_filter) = filter_list[i].id;
110+
if (IF_G(default_filter) != FILTER_DEFAULT) {
111+
zend_error(E_DEPRECATED, "The filter.default ini setting is deprecated");
112+
}
110113
return SUCCESS;
111114
}
112115
}

ext/filter/tests/004.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ GET/POST/REQUEST Test with filtered data
44
filter
55
--INI--
66
filter.default=special_chars
7+
error_reporting=E_ALL&~E_DEPRECATED
78
--POST--
89
d="quotes"&e=\slash
910
--GET--

ext/filter/tests/005.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ GET/REQUEST Test with fifa example data
44
filter
55
--INI--
66
filter.default=stripped
7+
error_reporting=E_ALL&~E_DEPRECATED
78
--GET--
89
id=f03_photos&pgurl=http%3A//fifaworldcup.yahoo.com/03/en/photozone/index.html
910
--FILE--

ext/filter/tests/041.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ filter
55
--INI--
66
filter.default=stripped
77
filter.default_flags=0
8+
error_reporting=E_ALL&~E_DEPRECATED
89
--COOKIE--
910
abc=dir; def=true; abc=root; xyz="foo bar";
1011
--FILE--
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
filter.default is deprecated
3+
--INI--
4+
filter.default=special_chars
5+
--FILE--
6+
<?php
7+
8+
echo "Done\n";
9+
10+
?>
11+
--EXPECT--
12+
Deprecated: The filter.default ini setting is deprecated in Unknown on line 0
13+
Done

0 commit comments

Comments
 (0)