xref: /PHP-7.4/ext/xml/tests/bug35447.phpt (revision 97200944)
1--TEST--
2Bug #35447 (xml_parse_into_struct() chokes on the UTF-8 BOM)
3--SKIPIF--
4<?php
5require_once("skipif.inc");
6if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this plattform");}
7?>
8--FILE--
9<?php
10$data = <<<END_OF_XML
11\xEF\xBB\xBF<?xml version="1.0" encoding="utf-8"?\x3e
12<!DOCTYPE bundle [
13    <!ELEMENT bundle (resource)+>
14    <!ELEMENT resource (#PCDATA)>
15    <!ATTLIST resource
16              key CDATA #REQUIRED
17              type (literal|pattern|sub) "literal"
18              >
19]>
20<resource key="rSeeYou">A bient&amp;244;t</resource>
21END_OF_XML;
22
23$parser = xml_parser_create_ns('UTF-8');
24xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
25$result = xml_parse_into_struct($parser, $data, $vals, $index);
26xml_parser_free($parser);
27var_dump($vals);
28?>
29--EXPECT--
30array(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}
50