File tree Expand file tree Collapse file tree 2 files changed +73
-0
lines changed Expand file tree Collapse file tree 2 files changed +73
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ replaceWith() without a parent
3
+ --EXTENSIONS--
4
+ dom
5
+ --FILE--
6
+ <?php
7
+ $ doc = new DOMDocument ;
8
+ $ doc ->loadXML (<<<XML
9
+ <?xml version="1.0"?>
10
+ <container>
11
+ <child/>
12
+ </container>
13
+ XML );
14
+
15
+ $ container = $ doc ->documentElement ;
16
+ $ child = $ container ->firstElementChild ;
17
+
18
+ $ test = $ doc ->createElement ('foo ' );
19
+ $ test ->replaceWith ($ child );
20
+ echo $ doc ->saveXML ();
21
+ echo $ doc ->saveXML ($ test );
22
+ ?>
23
+ --EXPECTF--
24
+ Fatal error: Uncaught DOMException: Not Found Error in %s:%d
25
+ Stack trace:
26
+ #0 %s(%d): DOMElement->replaceWith(Object(DOMElement))
27
+ #1 {main}
28
+ thrown in %s on line %d
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ replaceWith() with a non-variable next sibling
3
+ --EXTENSIONS--
4
+ dom
5
+ --FILE--
6
+ <?php
7
+ $ doc = new DOMDocument ;
8
+ $ doc ->loadXML (<<<XML
9
+ <?xml version="1.0"?>
10
+ <container>
11
+ <child>
12
+ <alone/>
13
+ </child>
14
+ </container>
15
+ XML );
16
+
17
+ $ container = $ doc ->documentElement ;
18
+ $ child = $ container ->firstElementChild ;
19
+ $ alone = $ child ->firstElementChild ;
20
+
21
+ $ child ->after ($ alone );
22
+ echo $ doc ->saveXML ();
23
+ $ child ->replaceWith ($ alone );
24
+ echo $ doc ->saveXML ();
25
+ ?>
26
+ --EXPECT--
27
+ <? xml version="1.0 "?>
28
+ <container>
29
+ <child>
30
+
31
+ </child><alone/>
32
+ </container>
33
+ <? xml version="1.0 "?>
34
+ <container>
35
+
36
+ </container>
37
+
38
+ =================================================================
39
+ ==1151863==ERROR: LeakSanitizer: detected memory leaks
40
+
41
+ Direct leak of 120 byte(s) in 1 object(s) allocated from:
42
+ #0 0x7fc122ee1369 in __interceptor_malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:69
43
+ #1 0x7fc122d02bd0 in xmlNewNodeEatName /home/niels/libxml2/tree.c:2317
44
+
45
+ SUMMARY: AddressSanitizer: 120 byte(s) leaked in 1 allocation(s).
You can’t perform that action at this time.
0 commit comments