File: bug35447.phpt

package info (click to toggle)
php8.4 8.4.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 211,276 kB
  • sloc: ansic: 1,176,142; php: 35,419; sh: 11,964; cpp: 7,208; pascal: 4,951; javascript: 3,091; asm: 2,817; yacc: 2,411; makefile: 696; xml: 446; python: 301; awk: 148
file content (50 lines) | stat: -rw-r--r-- 1,132 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
--TEST--
Bug #35447 (xml_parse_into_struct() chokes on the UTF-8 BOM)
--EXTENSIONS--
xml
--SKIPIF--
<?php
if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this platform");}
?>
--FILE--
<?php
$data = <<<END_OF_XML
\xEF\xBB\xBF<?xml version="1.0" encoding="utf-8"?\x3e
<!DOCTYPE bundle [
    <!ELEMENT bundle (resource)+>
    <!ELEMENT resource (#PCDATA)>
    <!ATTLIST resource
              key CDATA #REQUIRED
              type (literal|pattern|sub) "literal"
              >
]>
<resource key="rSeeYou">A bient&amp;244;t</resource>
END_OF_XML;

$parser = xml_parser_create_ns('UTF-8');
xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
$result = xml_parse_into_struct($parser, $data, $vals, $index);
xml_parser_free($parser);
var_dump($vals);
?>
--EXPECT--
array(1) {
  [0]=>
  array(5) {
    ["tag"]=>
    string(8) "resource"
    ["type"]=>
    string(8) "complete"
    ["level"]=>
    int(1)
    ["attributes"]=>
    array(2) {
      ["key"]=>
      string(7) "rSeeYou"
      ["type"]=>
      string(7) "literal"
    }
    ["value"]=>
    string(13) "A bient&244;t"
  }
}