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 "", //DEL 18 "€", //C1 19 "Ÿ", 20 " ", //allowed always 21 "퟿", //surrogates 22 "�", 23 "�", 24 "", //allowed always 25 "", //nonchar 26 "", 27 "﷏", //allowed always 28 "", //nonchar 29 "", 30 "ﷰ", //allowed always 31 "", //nonchar 32 "", 33); 34 35echo "*** HTML 4.01 ***\n"; 36 37foreach ($tests as $t) { 38 $dec = html_entity_decode($t, ENT_QUOTES | ENT_HTML401, "UTF-8"); 39 if ($t == $dec) { 40 echo "$t\tNOT DECODED\n"; 41 } else { 42 echo "$t\tDECODED\n"; 43 } 44} 45 46echo "\n*** XHTML 1.0 ***\n"; 47 48foreach ($tests as $t) { 49 $dec = html_entity_decode($t, ENT_QUOTES | ENT_XHTML, "UTF-8"); 50 if ($t == $dec) { 51 echo "$t\tNOT DECODED\n"; 52 } else { 53 echo "$t\tDECODED\n"; 54 } 55} 56 57echo "\n*** HTML5 ***\n"; 58 59foreach ($tests as $t) { 60 $dec = html_entity_decode($t, ENT_QUOTES | ENT_HTML5, "UTF-8"); 61 if ($t == $dec) { 62 echo "$t\tNOT DECODED\n"; 63 } else { 64 echo "$t\tDECODED\n"; 65 } 66} 67 68echo "\n*** XML 1.0 ***\n"; 69 70foreach ($tests as $t) { 71 $dec = html_entity_decode($t, ENT_QUOTES | ENT_XML1, "UTF-8"); 72 if ($t == $dec) { 73 echo "$t\tNOT DECODED\n"; 74 } else { 75 echo "$t\tDECODED\n"; 76 } 77} 78 79echo "\nDone.\n"; 80--EXPECT-- 81*** HTML 4.01 *** 82� NOT DECODED 83 NOT DECODED 84	 DECODED 85
 DECODED 86 NOT DECODED 87 NOT DECODED 88
 DECODED 89 NOT DECODED 90 NOT DECODED 91  DECODED 92 NOT DECODED 93€ NOT DECODED 94Ÿ NOT DECODED 95  DECODED 96퟿ DECODED 97� NOT DECODED 98� NOT DECODED 99 DECODED 100 DECODED 101 DECODED 102﷏ DECODED 103 DECODED 104 DECODED 105ﷰ DECODED 106 DECODED 107 DECODED 108 109*** XHTML 1.0 *** 110� NOT DECODED 111 NOT DECODED 112	 DECODED 113
 DECODED 114 NOT DECODED 115 NOT DECODED 116
 DECODED 117 NOT DECODED 118 NOT DECODED 119  DECODED 120 DECODED 121€ DECODED 122Ÿ DECODED 123  DECODED 124퟿ DECODED 125� NOT DECODED 126� NOT DECODED 127 DECODED 128 NOT DECODED 129 NOT DECODED 130﷏ DECODED 131 DECODED 132 DECODED 133ﷰ DECODED 134 DECODED 135 DECODED 136 137*** HTML5 *** 138� NOT DECODED 139 NOT DECODED 140	 DECODED 141
 DECODED 142 NOT DECODED 143 DECODED 144
 NOT DECODED 145 NOT DECODED 146 NOT DECODED 147  DECODED 148 NOT DECODED 149€ NOT DECODED 150Ÿ NOT DECODED 151  DECODED 152퟿ DECODED 153� NOT DECODED 154� NOT DECODED 155 DECODED 156 NOT DECODED 157 NOT DECODED 158﷏ DECODED 159 NOT DECODED 160 NOT DECODED 161ﷰ DECODED 162 NOT DECODED 163 NOT DECODED 164 165*** XML 1.0 *** 166� NOT DECODED 167 NOT DECODED 168	 DECODED 169
 DECODED 170 NOT DECODED 171 NOT DECODED 172
 DECODED 173 NOT DECODED 174 NOT DECODED 175  DECODED 176 DECODED 177€ DECODED 178Ÿ DECODED 179  DECODED 180퟿ DECODED 181� NOT DECODED 182� NOT DECODED 183 DECODED 184 NOT DECODED 185 NOT DECODED 186﷏ DECODED 187 DECODED 188 DECODED 189ﷰ DECODED 190 DECODED 191 DECODED 192 193Done. 194