xref: /PHP-8.2/ext/xml/tests/gh15868.phpt (revision ac8db365)
1--TEST--
2GH-15868 (Assertion failure in xml_parse_into_struct after exception)
3--EXTENSIONS--
4xml
5--FILE--
6<?php
7$parser = xml_parser_create();
8xml_set_element_handler($parser,
9    function ($parser, $name, $attrs) {
10        throw new Error('stop 1');
11    }, function ($parser, $name) {
12    }
13);
14try {
15    xml_parse_into_struct($parser, "<container/>", $values, $tags);
16} catch (Error $e) {
17    echo $e->getMessage(), "\n";
18}
19
20$parser = xml_parser_create();
21xml_set_element_handler($parser,
22    function ($parser, $name, $attrs) {
23    }, function ($parser, $name) {
24        throw new Error('stop 2');
25    }
26);
27try {
28    xml_parse_into_struct($parser, "<container/>", $values, $tags);
29} catch (Error $e) {
30    echo $e->getMessage(), "\n";
31}
32
33$parser = xml_parser_create();
34xml_set_character_data_handler($parser, function() {
35    throw new Error('stop 3');
36});
37try {
38    xml_parse_into_struct($parser, "<root><![CDATA[x]]></root>", $values, $tags);
39} catch (Error $e) {
40    echo $e->getMessage(), "\n";
41}
42?>
43--EXPECT--
44stop 1
45stop 2
46stop 3
47