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?> 93--EXPECT-- 94*** HTML 4.01 *** 95� NOT DECODED 96 NOT DECODED 97	 DECODED 98
 DECODED 99 NOT DECODED 100 NOT DECODED 101
 DECODED 102 NOT DECODED 103 NOT DECODED 104  DECODED 105' DECODED 106 NOT DECODED 107€ NOT DECODED 108Ÿ NOT DECODED 109  DECODED 110퟿ DECODED 111� NOT DECODED 112� NOT DECODED 113 DECODED 114 DECODED 115 DECODED 116﷏ DECODED 117 DECODED 118 DECODED 119ﷰ DECODED 120 DECODED 121 DECODED 122 123*** XHTML 1.0 *** 124� NOT DECODED 125 NOT DECODED 126	 DECODED 127
 DECODED 128 NOT DECODED 129 NOT DECODED 130
 DECODED 131 NOT DECODED 132 NOT DECODED 133  DECODED 134' DECODED 135 DECODED 136€ DECODED 137Ÿ DECODED 138  DECODED 139퟿ DECODED 140� NOT DECODED 141� NOT DECODED 142 DECODED 143 NOT DECODED 144 NOT DECODED 145﷏ DECODED 146 DECODED 147 DECODED 148ﷰ DECODED 149 DECODED 150 DECODED 151 152*** HTML5 *** 153� NOT DECODED 154 NOT DECODED 155	 DECODED 156
 DECODED 157 NOT DECODED 158 DECODED 159
 NOT DECODED 160 NOT DECODED 161 NOT DECODED 162  DECODED 163' DECODED 164 NOT DECODED 165€ NOT DECODED 166Ÿ NOT DECODED 167  DECODED 168퟿ DECODED 169� NOT DECODED 170� NOT DECODED 171 DECODED 172 NOT DECODED 173 NOT DECODED 174﷏ DECODED 175 NOT DECODED 176 NOT DECODED 177ﷰ DECODED 178 NOT DECODED 179 NOT DECODED 180 181*** XML 1.0 *** 182� NOT DECODED 183 NOT DECODED 184	 DECODED 185
 DECODED 186 NOT DECODED 187 NOT DECODED 188
 DECODED 189 NOT DECODED 190 NOT DECODED 191  DECODED 192' DECODED 193 DECODED 194€ DECODED 195Ÿ DECODED 196  DECODED 197퟿ DECODED 198� NOT DECODED 199� NOT DECODED 200 DECODED 201 NOT DECODED 202 NOT DECODED 203﷏ DECODED 204 DECODED 205 DECODED 206ﷰ DECODED 207 DECODED 208 DECODED 209 210*** Default options *** 211� NOT DECODED 212 NOT DECODED 213	 DECODED 214
 DECODED 215 NOT DECODED 216 NOT DECODED 217
 DECODED 218 NOT DECODED 219 NOT DECODED 220  DECODED 221' DECODED 222 NOT DECODED 223€ NOT DECODED 224Ÿ NOT DECODED 225  DECODED 226퟿ DECODED 227� NOT DECODED 228� NOT DECODED 229 DECODED 230 DECODED 231 DECODED 232﷏ DECODED 233 DECODED 234 DECODED 235ﷰ DECODED 236 DECODED 237 DECODED 238 239Done. 240