1--TEST-- 2html_entity_decode: Do not decode numerical entities that refer to non-SGML or otherwise disallowed chars 3--FILE-- 4<?php 5 6$tests = array( 7 "�", //C0 8 "", 9 "	", 10 "
", 11 "", 12 "", 13 "
", //note that HTML5 is unique in that it forbids this entity, but allows a literal U+0D 14 "", 15 "", 16 " ", //allowed always 17 "'", //single quote, depends on flags 18 "", //DEL 19 "€", //C1 20 "Ÿ", 21 " ", //allowed always 22 "퟿", //surrogates 23 "�", 24 "�", 25 "", //allowed always 26 "", //nonchar 27 "", 28 "﷏", //allowed always 29 "", //nonchar 30 "", 31 "ﷰ", //allowed always 32 "", //nonchar 33 "", 34); 35 36echo "*** HTML 4.01 ***\n"; 37 38foreach ($tests as $t) { 39 $dec = html_entity_decode($t, ENT_QUOTES | ENT_HTML401, "UTF-8"); 40 if ($t == $dec) { 41 echo "$t\tNOT DECODED\n"; 42 } else { 43 echo "$t\tDECODED\n"; 44 } 45} 46 47echo "\n*** XHTML 1.0 ***\n"; 48 49foreach ($tests as $t) { 50 $dec = html_entity_decode($t, ENT_QUOTES | ENT_XHTML, "UTF-8"); 51 if ($t == $dec) { 52 echo "$t\tNOT DECODED\n"; 53 } else { 54 echo "$t\tDECODED\n"; 55 } 56} 57 58echo "\n*** HTML5 ***\n"; 59 60foreach ($tests as $t) { 61 $dec = html_entity_decode($t, ENT_QUOTES | ENT_HTML5, "UTF-8"); 62 if ($t == $dec) { 63 echo "$t\tNOT DECODED\n"; 64 } else { 65 echo "$t\tDECODED\n"; 66 } 67} 68 69echo "\n*** XML 1.0 ***\n"; 70 71foreach ($tests as $t) { 72 $dec = html_entity_decode($t, ENT_QUOTES | ENT_XML1, "UTF-8"); 73 if ($t == $dec) { 74 echo "$t\tNOT DECODED\n"; 75 } else { 76 echo "$t\tDECODED\n"; 77 } 78} 79 80echo "\n*** Default options ***\n"; 81 82foreach ($tests as $t) { 83 $dec = html_entity_decode($t); 84 if ($t == $dec) { 85 echo "$t\tNOT DECODED\n"; 86 } else { 87 echo "$t\tDECODED\n"; 88 } 89} 90 91echo "\nDone.\n"; 92--EXPECT-- 93*** HTML 4.01 *** 94� NOT DECODED 95 NOT DECODED 96	 DECODED 97
 DECODED 98 NOT DECODED 99 NOT DECODED 100
 DECODED 101 NOT DECODED 102 NOT DECODED 103  DECODED 104' DECODED 105 NOT DECODED 106€ NOT DECODED 107Ÿ NOT DECODED 108  DECODED 109퟿ DECODED 110� NOT DECODED 111� NOT DECODED 112 DECODED 113 DECODED 114 DECODED 115﷏ DECODED 116 DECODED 117 DECODED 118ﷰ DECODED 119 DECODED 120 DECODED 121 122*** XHTML 1.0 *** 123� NOT DECODED 124 NOT DECODED 125	 DECODED 126
 DECODED 127 NOT DECODED 128 NOT DECODED 129
 DECODED 130 NOT DECODED 131 NOT DECODED 132  DECODED 133' DECODED 134 DECODED 135€ DECODED 136Ÿ DECODED 137  DECODED 138퟿ DECODED 139� NOT DECODED 140� NOT DECODED 141 DECODED 142 NOT DECODED 143 NOT DECODED 144﷏ DECODED 145 DECODED 146 DECODED 147ﷰ DECODED 148 DECODED 149 DECODED 150 151*** HTML5 *** 152� NOT DECODED 153 NOT DECODED 154	 DECODED 155
 DECODED 156 NOT DECODED 157 DECODED 158
 NOT DECODED 159 NOT DECODED 160 NOT DECODED 161  DECODED 162' DECODED 163 NOT DECODED 164€ NOT DECODED 165Ÿ NOT DECODED 166  DECODED 167퟿ DECODED 168� NOT DECODED 169� NOT DECODED 170 DECODED 171 NOT DECODED 172 NOT DECODED 173﷏ DECODED 174 NOT DECODED 175 NOT DECODED 176ﷰ DECODED 177 NOT DECODED 178 NOT DECODED 179 180*** XML 1.0 *** 181� NOT DECODED 182 NOT DECODED 183	 DECODED 184
 DECODED 185 NOT DECODED 186 NOT DECODED 187
 DECODED 188 NOT DECODED 189 NOT DECODED 190  DECODED 191' DECODED 192 DECODED 193€ DECODED 194Ÿ DECODED 195  DECODED 196퟿ DECODED 197� NOT DECODED 198� NOT DECODED 199 DECODED 200 NOT DECODED 201 NOT DECODED 202﷏ DECODED 203 DECODED 204 DECODED 205ﷰ DECODED 206 DECODED 207 DECODED 208 209*** Default options *** 210� NOT DECODED 211 NOT DECODED 212	 DECODED 213
 DECODED 214 NOT DECODED 215 NOT DECODED 216
 DECODED 217 NOT DECODED 218 NOT DECODED 219  DECODED 220' NOT DECODED 221 NOT DECODED 222€ NOT DECODED 223Ÿ NOT DECODED 224  DECODED 225퟿ DECODED 226� NOT DECODED 227� NOT DECODED 228 DECODED 229 DECODED 230 DECODED 231﷏ DECODED 232 DECODED 233 DECODED 234ﷰ DECODED 235 DECODED 236 DECODED 237 238Done. 239