xref: /PHP-8.3/ext/simplexml/tests/gh12223.phpt (revision 39a9e561)
1--TEST--
2GH-12223: Entity reference produces infinite loop in var_dump/print_r
3--EXTENSIONS--
4simplexml
5--FILE--
6<?php
7
8$xml = <<<XML
9<?xml version="1.0"?>
10<!DOCTYPE somedoc [
11  <!ENTITY a "something">
12  <!ENTITY b "&a;">
13  <!ENTITY c "&b;">
14]>
15<somedoc>&c;</somedoc>
16XML;
17
18$sxe = simplexml_load_string($xml);
19
20var_dump($sxe);
21print_r($sxe);
22
23?>
24--EXPECT--
25object(SimpleXMLElement)#1 (1) {
26  ["c"]=>
27  object(SimpleXMLElement)#2 (1) {
28    ["c"]=>
29    object(SimpleXMLElement)#3 (1) {
30      ["b"]=>
31      object(SimpleXMLElement)#4 (1) {
32        ["b"]=>
33        object(SimpleXMLElement)#5 (1) {
34          ["a"]=>
35          object(SimpleXMLElement)#6 (1) {
36            ["a"]=>
37            string(9) "something"
38          }
39        }
40      }
41    }
42  }
43}
44SimpleXMLElement Object
45(
46    [c] => SimpleXMLElement Object
47        (
48            [c] => SimpleXMLElement Object
49                (
50                    [b] => SimpleXMLElement Object
51                        (
52                            [b] => SimpleXMLElement Object
53                                (
54                                    [a] => SimpleXMLElement Object
55                                        (
56                                            [a] => something
57                                        )
58
59                                )
60
61                        )
62
63                )
64
65        )
66
67)
68