1--TEST-- 2htmlentities() / htmlspecialchars() ENT_DISALLOWED with entities and no double encode 3--FILE-- 4<?php 5$tests = array( 6 "�", //C0 7 "", 8 "	", 9 "
", 10 "", 11 "", 12 "
", //note that HTML5 is unique in that it forbids this entity, but allows a literal U+0D 13 "", 14 "", 15 " ", //allowed always 16 "", //DEL 17 "€", //C1 18 "Ÿ", 19 " ", //allowed always 20 "퟿", //surrogates 21 "�", 22 "�", 23 "", //allowed always 24 "", //nonchar 25 "", 26 "﷏", //allowed always 27 "", //nonchar 28 "", 29 "ﷰ", //allowed always 30 "", //nonchar 31 "", 32 "�", //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� NOT CHANGED 82 NOT CHANGED 83	 NOT CHANGED 84
 NOT CHANGED 85 NOT CHANGED 86 NOT CHANGED 87
 NOT CHANGED 88 NOT CHANGED 89 NOT CHANGED 90  NOT CHANGED 91 NOT CHANGED 92€ NOT CHANGED 93Ÿ NOT CHANGED 94  NOT CHANGED 95퟿ NOT CHANGED 96� NOT CHANGED 97� NOT CHANGED 98 NOT CHANGED 99 NOT CHANGED 100 NOT CHANGED 101﷏ NOT CHANGED 102 NOT CHANGED 103 NOT CHANGED 104ﷰ NOT CHANGED 105 NOT CHANGED 106 NOT CHANGED 107� CHANGED 108 109*** Testing XHTML 1.0 *** 110� CHANGED 111 CHANGED 112	 NOT CHANGED 113
 NOT CHANGED 114 CHANGED 115 CHANGED 116
 NOT CHANGED 117 CHANGED 118 CHANGED 119  NOT CHANGED 120 NOT CHANGED 121€ NOT CHANGED 122Ÿ NOT CHANGED 123  NOT CHANGED 124퟿ NOT CHANGED 125� CHANGED 126� CHANGED 127 NOT CHANGED 128 CHANGED 129 CHANGED 130﷏ NOT CHANGED 131 NOT CHANGED 132 NOT CHANGED 133ﷰ NOT CHANGED 134 NOT CHANGED 135 NOT CHANGED 136� CHANGED 137 138*** Testing HTML 5 *** 139� CHANGED (&#0;, &#0;) 140 CHANGED (&#1;, &#1;) 141	 NOT CHANGED 142
 NOT CHANGED 143 CHANGED (&#x0B;, &#x0B;) 144 NOT CHANGED 145
 CHANGED (&#x0D;, &#x0D;) 146 CHANGED (&#x0E;, &#x0E;) 147 CHANGED (&#x1F;, &#x1F;) 148  NOT CHANGED 149 CHANGED (&#x7F;, &#x7F;) 150€ CHANGED (&#x80;, &#x80;) 151Ÿ CHANGED (&#x9F;, &#x9F;) 152  NOT CHANGED 153퟿ NOT CHANGED 154� NOT CHANGED 155� NOT CHANGED 156 NOT CHANGED 157 CHANGED (&#xFFFE;, &#xFFFE;) 158 CHANGED (&#xFFFF;, &#xFFFF;) 159﷏ NOT CHANGED 160 CHANGED (&#xFDD0;, &#xFDD0;) 161 CHANGED (&#xFDEF;, &#xFDEF;) 162ﷰ NOT CHANGED 163 CHANGED (&#x2FFFE;, &#x2FFFE;) 164 CHANGED (&#x2FFFF;, &#x2FFFF;) 165� CHANGED (&#x110000;, &#x110000;) 166 167*** Testing XML 1.0 *** 168� CHANGED 169 CHANGED 170	 NOT CHANGED 171
 NOT CHANGED 172 CHANGED 173 CHANGED 174
 NOT CHANGED 175 CHANGED 176 CHANGED 177  NOT CHANGED 178 NOT CHANGED 179€ NOT CHANGED 180Ÿ NOT CHANGED 181  NOT CHANGED 182퟿ NOT CHANGED 183� CHANGED 184� CHANGED 185 NOT CHANGED 186 CHANGED 187 CHANGED 188﷏ NOT CHANGED 189 NOT CHANGED 190 NOT CHANGED 191ﷰ NOT CHANGED 192 NOT CHANGED 193 NOT CHANGED 194� CHANGED 195 196*** Testing 5 without the flag *** 197� NOT CHANGED 198 NOT CHANGED 199	 NOT CHANGED 200
 NOT CHANGED 201 NOT CHANGED 202 NOT CHANGED 203
 NOT CHANGED 204 NOT CHANGED 205 NOT CHANGED 206  NOT CHANGED 207 NOT CHANGED 208€ NOT CHANGED 209Ÿ NOT CHANGED 210  NOT CHANGED 211퟿ NOT CHANGED 212� NOT CHANGED 213� NOT CHANGED 214 NOT CHANGED 215 NOT CHANGED 216 NOT CHANGED 217﷏ NOT CHANGED 218 NOT CHANGED 219 NOT CHANGED 220ﷰ NOT CHANGED 221 NOT CHANGED 222 NOT CHANGED 223� CHANGED (&#x110000;, &#x110000;) 224 225*** Testing HTML 5 with another single-byte encoding *** 226� CHANGED (&#0;, &#0;) 227 CHANGED (&#1;, &#1;) 228	 NOT CHANGED 229
 NOT CHANGED 230 CHANGED (&#x0B;, &#x0B;) 231 NOT CHANGED 232
 CHANGED (&#x0D;, &#x0D;) 233 CHANGED (&#x0E;, &#x0E;) 234 CHANGED (&#x1F;, &#x1F;) 235  NOT CHANGED 236 CHANGED (&#x7F;, &#x7F;) 237€ CHANGED (&#x80;, &#x80;) 238Ÿ CHANGED (&#x9F;, &#x9F;) 239  NOT CHANGED 240퟿ NOT CHANGED 241� NOT CHANGED 242� NOT CHANGED 243 NOT CHANGED 244 CHANGED (&#xFFFE;, &#xFFFE;) 245 CHANGED (&#xFFFF;, &#xFFFF;) 246﷏ NOT CHANGED 247 CHANGED (&#xFDD0;, &#xFDD0;) 248 CHANGED (&#xFDEF;, &#xFDEF;) 249ﷰ NOT CHANGED 250 CHANGED (&#x2FFFE;, &#x2FFFE;) 251 CHANGED (&#x2FFFF;, &#x2FFFF;) 252� CHANGED (&#x110000;, &#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� 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 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	 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
 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 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 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
 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 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 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  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 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€ 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Ÿ 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  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퟿ 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� 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� 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 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 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 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﷏ 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 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 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ﷰ 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 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 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� CHANGED 336