bug35447.phpt 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. --TEST--
  2. Bug #35447 (xml_parse_into_struct() chokes on the UTF-8 BOM)
  3. --EXTENSIONS--
  4. xml
  5. --SKIPIF--
  6. <?php
  7. if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this platform");}
  8. ?>
  9. --FILE--
  10. <?php
  11. $data = <<<END_OF_XML
  12. \xEF\xBB\xBF<?xml version="1.0" encoding="utf-8"?\x3e
  13. <!DOCTYPE bundle [
  14. <!ELEMENT bundle (resource)+>
  15. <!ELEMENT resource (#PCDATA)>
  16. <!ATTLIST resource
  17. key CDATA #REQUIRED
  18. type (literal|pattern|sub) "literal"
  19. >
  20. ]>
  21. <resource key="rSeeYou">A bient&amp;244;t</resource>
  22. END_OF_XML;
  23. $parser = xml_parser_create_ns('UTF-8');
  24. xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
  25. $result = xml_parse_into_struct($parser, $data, $vals, $index);
  26. xml_parser_free($parser);
  27. var_dump($vals);
  28. ?>
  29. --EXPECT--
  30. array(1) {
  31. [0]=>
  32. array(5) {
  33. ["tag"]=>
  34. string(8) "resource"
  35. ["type"]=>
  36. string(8) "complete"
  37. ["level"]=>
  38. int(1)
  39. ["attributes"]=>
  40. array(2) {
  41. ["key"]=>
  42. string(7) "rSeeYou"
  43. ["type"]=>
  44. string(7) "literal"
  45. }
  46. ["value"]=>
  47. string(13) "A bient&244;t"
  48. }
  49. }