htmlentities21.phpt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. --TEST--
  2. htmlentities() / htmlspecialchars() ENT_DISALLOWED charset variation
  3. --FILE--
  4. <?php
  5. $tests = array(
  6. 0x00, //C0
  7. 0x01,
  8. 0x09,
  9. 0x0A,
  10. 0x0B,
  11. 0x0C,
  12. 0x0D,
  13. 0x0E,
  14. 0x1F,
  15. 0x20, //allowed always
  16. 0x7F, //DEL
  17. 0x80, //C1
  18. 0x9F,
  19. 0xA0, //allowed always
  20. );
  21. function test($flag, $charset) {
  22. global $tests;
  23. $i = -1;
  24. foreach ($tests as $test) {
  25. $test = chr($test);
  26. $i++;
  27. $a = htmlentities($test, $flag | ENT_DISALLOWED, $charset);
  28. $b = htmlspecialchars($test, $flag | ENT_DISALLOWED, $charset);
  29. if ($a == "" && $b == "") { echo sprintf("%05X", $tests[$i]), ": INVALID SEQUENCE\n"; continue; }
  30. echo sprintf("%05X", $tests[$i]), ": ", bin2hex($a), " ", bin2hex($b), "\n";
  31. }
  32. }
  33. echo "*** Testing HTML 4.01/Windows-1251 ***\n";
  34. test(ENT_HTML401, "Windows-1251");
  35. echo "\n*** Testing XHTML 1.0/Windows-1251 ***\n";
  36. test(ENT_XHTML, "Windows-1251");
  37. echo "\n*** Testing HTML 5/Windows-1251 ***\n";
  38. test(ENT_HTML5, "Windows-1251");
  39. echo "\n*** Testing XML 1.0/Windows-1251 ***\n";
  40. test(ENT_XML1, "Windows-1251");
  41. echo "\n*** Testing HTML 4.01/SJIS ***\n";
  42. test(ENT_HTML401, "SJIS");
  43. echo "\n*** Testing XHTML 1.0/SJIS ***\n";
  44. test(ENT_XHTML, "SJIS");
  45. echo "\n*** Testing HTML 5/SJIS ***\n";
  46. test(ENT_HTML5, "SJIS");
  47. echo "\n*** Testing XML 1.0/SJIS ***\n";
  48. test(ENT_XML1, "SJIS");
  49. ?>
  50. --EXPECTF--
  51. *** Testing HTML 4.01/Windows-1251 ***
  52. 00000: 262378464646443b 262378464646443b
  53. 00001: 262378464646443b 262378464646443b
  54. 00009: 09 09
  55. 0000A: 0a 0a
  56. 0000B: 262378464646443b 262378464646443b
  57. 0000C: 262378464646443b 262378464646443b
  58. 0000D: 0d 0d
  59. 0000E: 262378464646443b 262378464646443b
  60. 0001F: 262378464646443b 262378464646443b
  61. 00020: 20 20
  62. 0007F: 262378464646443b 7f
  63. 00080: 80 80
  64. 0009F: 9f 9f
  65. 000A0: 266e6273703b a0
  66. *** Testing XHTML 1.0/Windows-1251 ***
  67. 00000: 262378464646443b 262378464646443b
  68. 00001: 262378464646443b 262378464646443b
  69. 00009: 09 09
  70. 0000A: 0a 0a
  71. 0000B: 262378464646443b 262378464646443b
  72. 0000C: 262378464646443b 262378464646443b
  73. 0000D: 0d 0d
  74. 0000E: 262378464646443b 262378464646443b
  75. 0001F: 262378464646443b 262378464646443b
  76. 00020: 20 20
  77. 0007F: 7f 7f
  78. 00080: 80 80
  79. 0009F: 9f 9f
  80. 000A0: 266e6273703b a0
  81. *** Testing HTML 5/Windows-1251 ***
  82. 00000: 262378464646443b 262378464646443b
  83. 00001: 262378464646443b 262378464646443b
  84. 00009: 265461623b 09
  85. 0000A: 264e65774c696e653b 0a
  86. 0000B: 262378464646443b 262378464646443b
  87. 0000C: 0c 0c
  88. 0000D: 0d 0d
  89. 0000E: 262378464646443b 262378464646443b
  90. 0001F: 262378464646443b 262378464646443b
  91. 00020: 20 20
  92. 0007F: 262378464646443b 7f
  93. 00080: 26444a63793b 80
  94. 0009F: 26647a63793b 9f
  95. 000A0: 266e6273703b a0
  96. *** Testing XML 1.0/Windows-1251 ***
  97. 00000: 262378464646443b 262378464646443b
  98. 00001: 262378464646443b 262378464646443b
  99. 00009: 09 09
  100. 0000A: 0a 0a
  101. 0000B: 262378464646443b 262378464646443b
  102. 0000C: 262378464646443b 262378464646443b
  103. 0000D: 0d 0d
  104. 0000E: 262378464646443b 262378464646443b
  105. 0001F: 262378464646443b 262378464646443b
  106. 00020: 20 20
  107. 0007F: 7f 7f
  108. 00080: 80 80
  109. 0009F: 9f 9f
  110. 000A0: a0 a0
  111. *** Testing HTML 4.01/SJIS ***
  112. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  113. 00000: 262378464646443b 262378464646443b
  114. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  115. 00001: 262378464646443b 262378464646443b
  116. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  117. 00009: 09 09
  118. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  119. 0000A: 0a 0a
  120. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  121. 0000B: 262378464646443b 262378464646443b
  122. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  123. 0000C: 262378464646443b 262378464646443b
  124. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  125. 0000D: 0d 0d
  126. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  127. 0000E: 262378464646443b 262378464646443b
  128. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  129. 0001F: 262378464646443b 262378464646443b
  130. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  131. 00020: 20 20
  132. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  133. 0007F: 7f 7f
  134. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  135. 00080: INVALID SEQUENCE
  136. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  137. 0009F: INVALID SEQUENCE
  138. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  139. 000A0: INVALID SEQUENCE
  140. *** Testing XHTML 1.0/SJIS ***
  141. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  142. 00000: 262378464646443b 262378464646443b
  143. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  144. 00001: 262378464646443b 262378464646443b
  145. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  146. 00009: 09 09
  147. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  148. 0000A: 0a 0a
  149. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  150. 0000B: 262378464646443b 262378464646443b
  151. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  152. 0000C: 262378464646443b 262378464646443b
  153. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  154. 0000D: 0d 0d
  155. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  156. 0000E: 262378464646443b 262378464646443b
  157. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  158. 0001F: 262378464646443b 262378464646443b
  159. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  160. 00020: 20 20
  161. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  162. 0007F: 7f 7f
  163. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  164. 00080: INVALID SEQUENCE
  165. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  166. 0009F: INVALID SEQUENCE
  167. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  168. 000A0: INVALID SEQUENCE
  169. *** Testing HTML 5/SJIS ***
  170. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  171. 00000: 262378464646443b 262378464646443b
  172. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  173. 00001: 262378464646443b 262378464646443b
  174. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  175. 00009: 09 09
  176. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  177. 0000A: 0a 0a
  178. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  179. 0000B: 262378464646443b 262378464646443b
  180. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  181. 0000C: 0c 0c
  182. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  183. 0000D: 0d 0d
  184. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  185. 0000E: 262378464646443b 262378464646443b
  186. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  187. 0001F: 262378464646443b 262378464646443b
  188. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  189. 00020: 20 20
  190. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  191. 0007F: 7f 7f
  192. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  193. 00080: INVALID SEQUENCE
  194. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  195. 0009F: INVALID SEQUENCE
  196. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  197. 000A0: INVALID SEQUENCE
  198. *** Testing XML 1.0/SJIS ***
  199. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  200. 00000: 262378464646443b 262378464646443b
  201. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  202. 00001: 262378464646443b 262378464646443b
  203. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  204. 00009: 09 09
  205. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  206. 0000A: 0a 0a
  207. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  208. 0000B: 262378464646443b 262378464646443b
  209. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  210. 0000C: 262378464646443b 262378464646443b
  211. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  212. 0000D: 0d 0d
  213. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  214. 0000E: 262378464646443b 262378464646443b
  215. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  216. 0001F: 262378464646443b 262378464646443b
  217. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  218. 00020: 20 20
  219. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  220. 0007F: 7f 7f
  221. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  222. 00080: INVALID SEQUENCE
  223. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  224. 0009F: INVALID SEQUENCE
  225. Notice: htmlentities(): Only basic entities substitution is supported for multi-byte encodings other than UTF-8; functionality is equivalent to htmlspecialchars in %s line %d
  226. 000A0: INVALID SEQUENCE