1--TEST--
2htmlentities() / htmlspecialchars() ENT_DISALLOWED with entities and no double encode
3--FILE--
4<?php
5$tests = array(
6    "&#0;", //C0
7    "&#1;",
8    "&#x09;",
9    "&#x0A;",
10    "&#x0B;",
11    "&#x0C;",
12    "&#x0D;", //note that HTML5 is unique in that it forbids this entity, but allows a literal U+0D
13    "&#x0E;",
14    "&#x1F;",
15    "&#x20;", //allowed always
16    "&#x7F;", //DEL
17    "&#x80;", //C1
18    "&#x9F;",
19    "&#xA0;", //allowed always
20    "&#xD7FF;", //surrogates
21    "&#xD800;",
22    "&#xDFFF;",
23    "&#xE000;", //allowed always
24    "&#xFFFE;", //nonchar
25    "&#xFFFF;",
26    "&#xFDCF;", //allowed always
27    "&#xFDD0;", //nonchar
28    "&#xFDEF;",
29    "&#xFDF0;", //allowed always
30    "&#x2FFFE;", //nonchar
31    "&#x2FFFF;",
32    "&#x110000;", //bad reference
33);
34
35function test($flag, $flag2=ENT_DISALLOWED, $charset="UTF-8") {
36    global $tests;
37    $i = -1;
38    foreach ($tests as $test) {
39        $i++;
40        $a = htmlentities($test, $flag | $flag2, $charset, FALSE);
41        $b = htmlspecialchars($test, $flag | $flag2, $charset, FALSE);
42
43        if ($a == $b)
44            echo sprintf("%s\t%s", $test, $a==$test?"NOT CHANGED":"CHANGED"), "\n";
45        else
46            echo sprintf("%s\tCHANGED (%s, %s)", $test, $a, $b), "\n";
47    }
48}
49
50echo "*** Testing HTML 4.01 ***\n";
51
52test(ENT_HTML401);
53
54echo "\n*** Testing XHTML 1.0 ***\n";
55
56test(ENT_XHTML);
57
58echo "\n*** Testing HTML 5 ***\n";
59
60test(ENT_HTML5);
61
62echo "\n*** Testing XML 1.0 ***\n";
63
64test(ENT_XML1);
65
66echo "\n*** Testing 5 without the flag ***\n";
67
68test(ENT_HTML5, 0);
69
70echo "\n*** Testing HTML 5 with another single-byte encoding ***\n";
71
72test(ENT_HTML5, ENT_DISALLOWED, "Windows-1251");
73
74echo "\n*** Testing HTML 5 with another multibyte-byte encoding ***\n";
75
76test(ENT_HTML5, ENT_DISALLOWED, "SJIS");
77
78?>
79--EXPECTF--
80*** Testing HTML 4.01 ***
81&#0;	NOT CHANGED
82&#1;	NOT CHANGED
83&#x09;	NOT CHANGED
84&#x0A;	NOT CHANGED
85&#x0B;	NOT CHANGED
86&#x0C;	NOT CHANGED
87&#x0D;	NOT CHANGED
88&#x0E;	NOT CHANGED
89&#x1F;	NOT CHANGED
90&#x20;	NOT CHANGED
91&#x7F;	NOT CHANGED
92&#x80;	NOT CHANGED
93&#x9F;	NOT CHANGED
94&#xA0;	NOT CHANGED
95&#xD7FF;	NOT CHANGED
96&#xD800;	NOT CHANGED
97&#xDFFF;	NOT CHANGED
98&#xE000;	NOT CHANGED
99&#xFFFE;	NOT CHANGED
100&#xFFFF;	NOT CHANGED
101&#xFDCF;	NOT CHANGED
102&#xFDD0;	NOT CHANGED
103&#xFDEF;	NOT CHANGED
104&#xFDF0;	NOT CHANGED
105&#x2FFFE;	NOT CHANGED
106&#x2FFFF;	NOT CHANGED
107&#x110000;	CHANGED
108
109*** Testing XHTML 1.0 ***
110&#0;	CHANGED
111&#1;	CHANGED
112&#x09;	NOT CHANGED
113&#x0A;	NOT CHANGED
114&#x0B;	CHANGED
115&#x0C;	CHANGED
116&#x0D;	NOT CHANGED
117&#x0E;	CHANGED
118&#x1F;	CHANGED
119&#x20;	NOT CHANGED
120&#x7F;	NOT CHANGED
121&#x80;	NOT CHANGED
122&#x9F;	NOT CHANGED
123&#xA0;	NOT CHANGED
124&#xD7FF;	NOT CHANGED
125&#xD800;	CHANGED
126&#xDFFF;	CHANGED
127&#xE000;	NOT CHANGED
128&#xFFFE;	CHANGED
129&#xFFFF;	CHANGED
130&#xFDCF;	NOT CHANGED
131&#xFDD0;	NOT CHANGED
132&#xFDEF;	NOT CHANGED
133&#xFDF0;	NOT CHANGED
134&#x2FFFE;	NOT CHANGED
135&#x2FFFF;	NOT CHANGED
136&#x110000;	CHANGED
137
138*** Testing HTML 5 ***
139&#0;	CHANGED (&amp;&num;0&semi;, &amp;#0;)
140&#1;	CHANGED (&amp;&num;1&semi;, &amp;#1;)
141&#x09;	NOT CHANGED
142&#x0A;	NOT CHANGED
143&#x0B;	CHANGED (&amp;&num;x0B&semi;, &amp;#x0B;)
144&#x0C;	NOT CHANGED
145&#x0D;	CHANGED (&amp;&num;x0D&semi;, &amp;#x0D;)
146&#x0E;	CHANGED (&amp;&num;x0E&semi;, &amp;#x0E;)
147&#x1F;	CHANGED (&amp;&num;x1F&semi;, &amp;#x1F;)
148&#x20;	NOT CHANGED
149&#x7F;	CHANGED (&amp;&num;x7F&semi;, &amp;#x7F;)
150&#x80;	CHANGED (&amp;&num;x80&semi;, &amp;#x80;)
151&#x9F;	CHANGED (&amp;&num;x9F&semi;, &amp;#x9F;)
152&#xA0;	NOT CHANGED
153&#xD7FF;	NOT CHANGED
154&#xD800;	NOT CHANGED
155&#xDFFF;	NOT CHANGED
156&#xE000;	NOT CHANGED
157&#xFFFE;	CHANGED (&amp;&num;xFFFE&semi;, &amp;#xFFFE;)
158&#xFFFF;	CHANGED (&amp;&num;xFFFF&semi;, &amp;#xFFFF;)
159&#xFDCF;	NOT CHANGED
160&#xFDD0;	CHANGED (&amp;&num;xFDD0&semi;, &amp;#xFDD0;)
161&#xFDEF;	CHANGED (&amp;&num;xFDEF&semi;, &amp;#xFDEF;)
162&#xFDF0;	NOT CHANGED
163&#x2FFFE;	CHANGED (&amp;&num;x2FFFE&semi;, &amp;#x2FFFE;)
164&#x2FFFF;	CHANGED (&amp;&num;x2FFFF&semi;, &amp;#x2FFFF;)
165&#x110000;	CHANGED (&amp;&num;x110000&semi;, &amp;#x110000;)
166
167*** Testing XML 1.0 ***
168&#0;	CHANGED
169&#1;	CHANGED
170&#x09;	NOT CHANGED
171&#x0A;	NOT CHANGED
172&#x0B;	CHANGED
173&#x0C;	CHANGED
174&#x0D;	NOT CHANGED
175&#x0E;	CHANGED
176&#x1F;	CHANGED
177&#x20;	NOT CHANGED
178&#x7F;	NOT CHANGED
179&#x80;	NOT CHANGED
180&#x9F;	NOT CHANGED
181&#xA0;	NOT CHANGED
182&#xD7FF;	NOT CHANGED
183&#xD800;	CHANGED
184&#xDFFF;	CHANGED
185&#xE000;	NOT CHANGED
186&#xFFFE;	CHANGED
187&#xFFFF;	CHANGED
188&#xFDCF;	NOT CHANGED
189&#xFDD0;	NOT CHANGED
190&#xFDEF;	NOT CHANGED
191&#xFDF0;	NOT CHANGED
192&#x2FFFE;	NOT CHANGED
193&#x2FFFF;	NOT CHANGED
194&#x110000;	CHANGED
195
196*** Testing 5 without the flag ***
197&#0;	NOT CHANGED
198&#1;	NOT CHANGED
199&#x09;	NOT CHANGED
200&#x0A;	NOT CHANGED
201&#x0B;	NOT CHANGED
202&#x0C;	NOT CHANGED
203&#x0D;	NOT CHANGED
204&#x0E;	NOT CHANGED
205&#x1F;	NOT CHANGED
206&#x20;	NOT CHANGED
207&#x7F;	NOT CHANGED
208&#x80;	NOT CHANGED
209&#x9F;	NOT CHANGED
210&#xA0;	NOT CHANGED
211&#xD7FF;	NOT CHANGED
212&#xD800;	NOT CHANGED
213&#xDFFF;	NOT CHANGED
214&#xE000;	NOT CHANGED
215&#xFFFE;	NOT CHANGED
216&#xFFFF;	NOT CHANGED
217&#xFDCF;	NOT CHANGED
218&#xFDD0;	NOT CHANGED
219&#xFDEF;	NOT CHANGED
220&#xFDF0;	NOT CHANGED
221&#x2FFFE;	NOT CHANGED
222&#x2FFFF;	NOT CHANGED
223&#x110000;	CHANGED (&amp;&num;x110000&semi;, &amp;#x110000;)
224
225*** Testing HTML 5 with another single-byte encoding ***
226&#0;	CHANGED (&amp;&num;0&semi;, &amp;#0;)
227&#1;	CHANGED (&amp;&num;1&semi;, &amp;#1;)
228&#x09;	NOT CHANGED
229&#x0A;	NOT CHANGED
230&#x0B;	CHANGED (&amp;&num;x0B&semi;, &amp;#x0B;)
231&#x0C;	NOT CHANGED
232&#x0D;	CHANGED (&amp;&num;x0D&semi;, &amp;#x0D;)
233&#x0E;	CHANGED (&amp;&num;x0E&semi;, &amp;#x0E;)
234&#x1F;	CHANGED (&amp;&num;x1F&semi;, &amp;#x1F;)
235&#x20;	NOT CHANGED
236&#x7F;	CHANGED (&amp;&num;x7F&semi;, &amp;#x7F;)
237&#x80;	CHANGED (&amp;&num;x80&semi;, &amp;#x80;)
238&#x9F;	CHANGED (&amp;&num;x9F&semi;, &amp;#x9F;)
239&#xA0;	NOT CHANGED
240&#xD7FF;	NOT CHANGED
241&#xD800;	NOT CHANGED
242&#xDFFF;	NOT CHANGED
243&#xE000;	NOT CHANGED
244&#xFFFE;	CHANGED (&amp;&num;xFFFE&semi;, &amp;#xFFFE;)
245&#xFFFF;	CHANGED (&amp;&num;xFFFF&semi;, &amp;#xFFFF;)
246&#xFDCF;	NOT CHANGED
247&#xFDD0;	CHANGED (&amp;&num;xFDD0&semi;, &amp;#xFDD0;)
248&#xFDEF;	CHANGED (&amp;&num;xFDEF&semi;, &amp;#xFDEF;)
249&#xFDF0;	NOT CHANGED
250&#x2FFFE;	CHANGED (&amp;&num;x2FFFE&semi;, &amp;#x2FFFE;)
251&#x2FFFF;	CHANGED (&amp;&num;x2FFFF&semi;, &amp;#x2FFFF;)
252&#x110000;	CHANGED (&amp;&num;x110000&semi;, &amp;#x110000;)
253
254*** Testing HTML 5 with another multibyte-byte encoding ***
255
256Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
257&#0;	CHANGED
258
259Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
260&#1;	CHANGED
261
262Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
263&#x09;	NOT CHANGED
264
265Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
266&#x0A;	NOT CHANGED
267
268Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
269&#x0B;	CHANGED
270
271Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
272&#x0C;	NOT CHANGED
273
274Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
275&#x0D;	CHANGED
276
277Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
278&#x0E;	CHANGED
279
280Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
281&#x1F;	CHANGED
282
283Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
284&#x20;	NOT CHANGED
285
286Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
287&#x7F;	CHANGED
288
289Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
290&#x80;	CHANGED
291
292Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
293&#x9F;	CHANGED
294
295Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
296&#xA0;	NOT CHANGED
297
298Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
299&#xD7FF;	NOT CHANGED
300
301Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
302&#xD800;	NOT CHANGED
303
304Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
305&#xDFFF;	NOT CHANGED
306
307Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
308&#xE000;	NOT CHANGED
309
310Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
311&#xFFFE;	CHANGED
312
313Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
314&#xFFFF;	CHANGED
315
316Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
317&#xFDCF;	NOT CHANGED
318
319Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
320&#xFDD0;	CHANGED
321
322Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
323&#xFDEF;	CHANGED
324
325Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
326&#xFDF0;	NOT CHANGED
327
328Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
329&#x2FFFE;	CHANGED
330
331Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
332&#x2FFFF;	CHANGED
333
334Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
335&#x110000;	CHANGED
336