Skip to content

Commit 3a5664f

Browse files
Girgiasnikic
authored andcommitted
Convert E_STRICT into E_NOTICE for htmlentities() function
1 parent 3f23380 commit 3a5664f

File tree

10 files changed

+209
-17
lines changed

10 files changed

+209
-17
lines changed

UPGRADING

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ PHP 7.4 UPGRADE NOTES
135135
Applications correctly using the constants PASSWORD_DEFAULT,
136136
PASSWORD_BCRYPT, PASSWORD_ARGON2I, and PASSWORD_ARGON2ID will continue to
137137
function correctly.
138+
. htmlentities() will now throw a notice (instead of a strict standards
139+
warning) if it is used with an encoding for which only basic entity
140+
substitution is supported, in which case it is equivalent to
141+
htmlspecialchars().
138142

139143
- Tokenizer:
140144
. token_get_all() will now emit a T_BAD_CHARACTER token for unexpected

ext/standard/html.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ PHPAPI zend_string *php_escape_html_entities_ex(unsigned char *old, size_t oldle
11871187

11881188
if (all) { /* replace with all named entities */
11891189
if (CHARSET_PARTIAL_SUPPORT(charset)) {
1190-
php_error_docref(NULL, E_STRICT, "Only basic entities "
1190+
php_error_docref(NULL, E_NOTICE, "Only basic entities "
11911191
"substitution is supported for multi-byte encodings other than UTF-8; "
11921192
"functionality is equivalent to htmlspecialchars");
11931193
}

ext/standard/tests/strings/htmlentities04.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ internal_encoding=pass
1717
var_dump(htmlentities("\xa1\xa2\xa1\xa3\xa1\xa4", ENT_QUOTES, ''));
1818
?>
1919
--EXPECTF--
20-
Strict Standards: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
20+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
2121
string(6) "¡¢¡£¡¤"

ext/standard/tests/strings/htmlentities08.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
htmlentities() test 8 (mbstring / EUC-JP)
33
--INI--
44
output_handler=
5-
error_reporting=~E_STRICT
65
internal_encoding=EUC-JP
76
--SKIPIF--
87
<?php
@@ -13,6 +12,8 @@ internal_encoding=EUC-JP
1312
print mb_internal_encoding()."\n";
1413
var_dump(htmlentities("\xa1\xa2\xa1\xa3\xa1\xa4", ENT_QUOTES, ''));
1514
?>
16-
--EXPECT--
15+
--EXPECTF--
1716
EUC-JP
17+
18+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
1819
string(6) "¡¢¡£¡¤"

ext/standard/tests/strings/htmlentities09.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
htmlentities() test 9 (mbstring / Shift_JIS)
33
--INI--
44
output_handler=
5-
error_reporting=~E_STRICT
65
internal_encoding=Shift_JIS
76
--SKIPIF--
87
<?php
@@ -14,7 +13,9 @@ internal_encoding=Shift_JIS
1413
var_dump(bin2hex(htmlentities("\x81\x41\x81\x42\x81\x43", ENT_QUOTES, '')));
1514
?>
1615
===DONE===
17-
--EXPECT--
16+
--EXPECTF--
1817
SJIS
18+
19+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
1920
string(12) "814181428143"
2021
===DONE===

ext/standard/tests/strings/htmlentities13.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ filter.default=unsafe_raw
1313
--EXPECTF--
1414
EUC-JP
1515

16-
Strict Standards: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s on line %d
16+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s on line %d
1717
string(6) "¡¢¡£¡¤"

ext/standard/tests/strings/htmlentities14.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ filter.default=unsafe_raw
1313
--EXPECTF--
1414
Shift_JIS
1515

16-
Strict Standards: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s on line %d
16+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s on line %d
1717
string(6) "ABC"

ext/standard/tests/strings/htmlentities21.phpt

Lines changed: 113 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ $tests = array(
2222
function test($flag, $charset) {
2323
global $tests;
2424
$i = -1;
25-
error_reporting(-1 & ~E_STRICT);
2625
foreach ($tests as $test) {
2726
$test = chr($test);
2827
$i++;
@@ -31,7 +30,6 @@ function test($flag, $charset) {
3130
if ($a == "" && $b == "") { echo sprintf("%05X", $tests[$i]), ": INVALID SEQUENCE\n"; continue; }
3231
echo sprintf("%05X", $tests[$i]), ": ", bin2hex($a), " ", bin2hex($b), "\n";
3332
}
34-
error_reporting(-1);
3533
}
3634

3735
echo "*** Testing HTML 4.01/Windows-1251 ***\n";
@@ -68,7 +66,7 @@ test(ENT_XML1, "SJIS");
6866

6967

7068
?>
71-
--EXPECT--
69+
--EXPECTF--
7270
*** Testing HTML 4.01/Windows-1251 ***
7371
00000: 262378464646443b 262378464646443b
7472
00001: 262378464646443b 262378464646443b
@@ -134,65 +132,177 @@ test(ENT_XML1, "SJIS");
134132
000A0: a0 a0
135133

136134
*** Testing HTML 4.01/SJIS ***
135+
136+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
137137
00000: 262378464646443b 262378464646443b
138+
139+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
138140
00001: 262378464646443b 262378464646443b
141+
142+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
139143
00009: 09 09
144+
145+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
140146
0000A: 0a 0a
147+
148+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
141149
0000B: 262378464646443b 262378464646443b
150+
151+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
142152
0000C: 262378464646443b 262378464646443b
153+
154+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
143155
0000D: 0d 0d
156+
157+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
144158
0000E: 262378464646443b 262378464646443b
159+
160+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
145161
0001F: 262378464646443b 262378464646443b
162+
163+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
146164
00020: 20 20
165+
166+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
147167
0007F: 7f 7f
168+
169+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
148170
00080: INVALID SEQUENCE
171+
172+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
149173
0009F: INVALID SEQUENCE
174+
175+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
150176
000A0: INVALID SEQUENCE
151177

152178
*** Testing XHTML 1.0/SJIS ***
179+
180+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
153181
00000: 262378464646443b 262378464646443b
182+
183+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
154184
00001: 262378464646443b 262378464646443b
185+
186+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
155187
00009: 09 09
188+
189+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
156190
0000A: 0a 0a
191+
192+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
157193
0000B: 262378464646443b 262378464646443b
194+
195+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
158196
0000C: 262378464646443b 262378464646443b
197+
198+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
159199
0000D: 0d 0d
200+
201+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
160202
0000E: 262378464646443b 262378464646443b
203+
204+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
161205
0001F: 262378464646443b 262378464646443b
206+
207+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
162208
00020: 20 20
209+
210+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
163211
0007F: 7f 7f
212+
213+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
164214
00080: INVALID SEQUENCE
215+
216+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
165217
0009F: INVALID SEQUENCE
218+
219+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
166220
000A0: INVALID SEQUENCE
167221

168222
*** Testing HTML 5/SJIS ***
223+
224+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
169225
00000: 262378464646443b 262378464646443b
226+
227+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
170228
00001: 262378464646443b 262378464646443b
229+
230+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
171231
00009: 09 09
232+
233+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
172234
0000A: 0a 0a
235+
236+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
173237
0000B: 262378464646443b 262378464646443b
238+
239+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
174240
0000C: 0c 0c
241+
242+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
175243
0000D: 0d 0d
244+
245+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
176246
0000E: 262378464646443b 262378464646443b
247+
248+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
177249
0001F: 262378464646443b 262378464646443b
250+
251+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
178252
00020: 20 20
253+
254+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
179255
0007F: 7f 7f
256+
257+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
180258
00080: INVALID SEQUENCE
259+
260+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
181261
0009F: INVALID SEQUENCE
262+
263+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
182264
000A0: INVALID SEQUENCE
183265

184266
*** Testing XML 1.0/SJIS ***
267+
268+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
185269
00000: 262378464646443b 262378464646443b
270+
271+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
186272
00001: 262378464646443b 262378464646443b
273+
274+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
187275
00009: 09 09
276+
277+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
188278
0000A: 0a 0a
279+
280+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
189281
0000B: 262378464646443b 262378464646443b
282+
283+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
190284
0000C: 262378464646443b 262378464646443b
285+
286+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
191287
0000D: 0d 0d
288+
289+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
192290
0000E: 262378464646443b 262378464646443b
291+
292+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
193293
0001F: 262378464646443b 262378464646443b
294+
295+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
194296
00020: 20 20
297+
298+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
195299
0007F: 7f 7f
300+
301+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
196302
00080: INVALID SEQUENCE
303+
304+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
197305
0009F: INVALID SEQUENCE
306+
307+
Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
198308
000A0: INVALID SEQUENCE

0 commit comments

Comments
 (0)