1<?php
2
3namespace Sabre\Xml;
4
5class InfiteLoopTest extends \PHPUnit_Framework_TestCase {
6
7    /**
8     * This particular xml body caused the parser to go into an infinite loop.
9     * Need to know why.
10     */
11    function testDeserialize() {
12
13        $body = '<?xml version="1.0"?>
14<d:propertyupdate xmlns:d="DAV:" xmlns:s="http://sabredav.org/NS/test">
15  <d:set><d:prop></d:prop></d:set>
16  <d:set><d:prop></d:prop></d:set>
17</d:propertyupdate>';
18
19        $reader = new Reader();
20        $reader->elementMap = [
21            '{DAV:}set' => 'Sabre\\Xml\\Element\\KeyValue',
22        ];
23        $reader->xml($body);
24
25        $output = $reader->parse();
26
27        $this->assertEquals([
28            'name'  => '{DAV:}propertyupdate',
29            'value' => [
30                [
31                    'name'  => '{DAV:}set',
32                    'value' => [
33                        '{DAV:}prop' => null,
34                    ],
35                    'attributes' => [],
36                ],
37                [
38                    'name'  => '{DAV:}set',
39                    'value' => [
40                        '{DAV:}prop' => null,
41                    ],
42                    'attributes' => [],
43                ],
44            ],
45            'attributes' => [],
46        ], $output);
47
48    }
49
50}
51