xref: /php-src/ext/xml/tests/bug35447.phpt (revision 8567bc10)
1--TEST--
2Bug #35447 (xml_parse_into_struct() chokes on the UTF-8 BOM)
3--EXTENSIONS--
4xml
5--SKIPIF--
6<?php
7if (! @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>
22END_OF_XML;
23
24$parser = xml_parser_create_ns('UTF-8');
25xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
26$result = xml_parse_into_struct($parser, $data, $vals, $index);
27xml_parser_free($parser);
28var_dump($vals);
29?>
30--EXPECT--
31array(1) {
32  [0]=>
33  array(5) {
34    ["tag"]=>
35    string(8) "resource"
36    ["type"]=>
37    string(8) "complete"
38    ["level"]=>
39    int(1)
40    ["attributes"]=>
41    array(2) {
42      ["key"]=>
43      string(7) "rSeeYou"
44      ["type"]=>
45      string(7) "literal"
46    }
47    ["value"]=>
48    string(13) "A bient&244;t"
49  }
50}
51