|
| 1 | +--TEST-- |
| 2 | +Bug #80602 (Segfault when using DOMChildNode::before()) |
| 3 | +--FILE-- |
| 4 | +<?php |
| 5 | +declare(strict_types=1); |
| 6 | + |
| 7 | +$doc = new \DOMDocument(); |
| 8 | +$doc->loadXML('<a>foo<last/></a>'); |
| 9 | +$target = $doc->documentElement->firstChild; |
| 10 | +$target->before($target); |
| 11 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 12 | + |
| 13 | +$doc = new \DOMDocument(); |
| 14 | +$doc->loadXML('<a>foo<last/></a>'); |
| 15 | +$target = $doc->documentElement->lastChild; |
| 16 | +$target->before($target); |
| 17 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 18 | + |
| 19 | + |
| 20 | +$doc = new \DOMDocument(); |
| 21 | +$doc->loadXML('<a>foo<last/></a>'); |
| 22 | +$target = $doc->documentElement->firstChild; |
| 23 | +$target->before($doc->documentElement->lastChild); |
| 24 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 25 | + |
| 26 | +$doc = new \DOMDocument(); |
| 27 | +$doc->loadXML('<a>foo<last/></a>'); |
| 28 | +$target = $doc->documentElement->lastChild; |
| 29 | +$target->before($doc->documentElement->firstChild); |
| 30 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 31 | + |
| 32 | + |
| 33 | +$doc = new \DOMDocument(); |
| 34 | +$doc->loadXML('<a>foo<last/></a>'); |
| 35 | +$target = $doc->documentElement->firstChild; |
| 36 | +$target->before($target, $doc->documentElement->lastChild); |
| 37 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 38 | + |
| 39 | +$doc = new \DOMDocument(); |
| 40 | +$doc->loadXML('<a>foo<last/></a>'); |
| 41 | +$target = $doc->documentElement->firstChild; |
| 42 | +$target->before($doc->documentElement->lastChild, $target); |
| 43 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 44 | + |
| 45 | + |
| 46 | +$doc = new \DOMDocument(); |
| 47 | +$doc->loadXML('<a>foo<last/></a>'); |
| 48 | +$target = $doc->documentElement->lastChild; |
| 49 | +$target->before($target, $doc->documentElement->firstChild); |
| 50 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 51 | + |
| 52 | +$doc = new \DOMDocument(); |
| 53 | +$doc->loadXML('<a>foo<last/></a>'); |
| 54 | +$target = $doc->documentElement->lastChild; |
| 55 | +$target->before($doc->documentElement->firstChild, $target); |
| 56 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 57 | + |
| 58 | + |
| 59 | +$doc = new \DOMDocument(); |
| 60 | +$doc->loadXML('<a>foo<last/></a>'); |
| 61 | +$target = $doc->documentElement->firstChild; |
| 62 | +$target->before('bar','baz'); |
| 63 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 64 | + |
| 65 | +$doc = new \DOMDocument(); |
| 66 | +$doc->loadXML('<a>foo<last/></a>'); |
| 67 | +$target = $doc->documentElement->lastChild; |
| 68 | +$target->before('bar','baz'); |
| 69 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 70 | + |
| 71 | + |
| 72 | +$doc = new \DOMDocument(); |
| 73 | +$doc->loadXML('<a>foo<last/></a>'); |
| 74 | +$target = $doc->documentElement->firstChild; |
| 75 | +$target->before($target, 'bar','baz'); |
| 76 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 77 | + |
| 78 | +$doc = new \DOMDocument(); |
| 79 | +$doc->loadXML('<a>foo<last/></a>'); |
| 80 | +$target = $doc->documentElement->firstChild; |
| 81 | +$target->before('bar', $target, 'baz'); |
| 82 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 83 | + |
| 84 | +$doc = new \DOMDocument(); |
| 85 | +$doc->loadXML('<a>foo<last/></a>'); |
| 86 | +$target = $doc->documentElement->firstChild; |
| 87 | +$target->before('bar', 'baz', $target); |
| 88 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | +$doc = new \DOMDocument(); |
| 93 | +$doc->loadXML('<a>foo<last/></a>'); |
| 94 | +$target = $doc->documentElement->lastChild; |
| 95 | +$target->before($target, 'bar','baz'); |
| 96 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 97 | + |
| 98 | +$doc = new \DOMDocument(); |
| 99 | +$doc->loadXML('<a>foo<last/></a>'); |
| 100 | +$target = $doc->documentElement->lastChild; |
| 101 | +$target->before('bar', $target, 'baz'); |
| 102 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 103 | + |
| 104 | +$doc = new \DOMDocument(); |
| 105 | +$doc->loadXML('<a>foo<last/></a>'); |
| 106 | +$target = $doc->documentElement->lastChild; |
| 107 | +$target->before('bar', 'baz', $target); |
| 108 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | +$doc = new \DOMDocument(); |
| 113 | +$doc->loadXML('<a>foo<last/></a>'); |
| 114 | +$target = $doc->documentElement->firstChild; |
| 115 | +$target->before('bar', $target, $doc->documentElement->lastChild); |
| 116 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 117 | + |
| 118 | + |
| 119 | +$doc = new \DOMDocument(); |
| 120 | +$doc->loadXML('<a>foo<last/></a>'); |
| 121 | +$target = $doc->documentElement->firstChild; |
| 122 | +$target->before($target, 'bar', $doc->documentElement->lastChild); |
| 123 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 124 | + |
| 125 | + |
| 126 | +$doc = new \DOMDocument(); |
| 127 | +$doc->loadXML('<a>foo<last/></a>'); |
| 128 | +$target = $doc->documentElement->firstChild; |
| 129 | +$target->before($target, $doc->documentElement->lastChild, 'bar'); |
| 130 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 131 | + |
| 132 | + |
| 133 | + |
| 134 | + |
| 135 | +$doc = new \DOMDocument(); |
| 136 | +$doc->loadXML('<a>foo<last/></a>'); |
| 137 | +$target = $doc->documentElement->lastChild; |
| 138 | +$target->before('bar', $doc->documentElement->firstChild, $target); |
| 139 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 140 | + |
| 141 | + |
| 142 | +$doc = new \DOMDocument(); |
| 143 | +$doc->loadXML('<a>foo<last/></a>'); |
| 144 | +$target = $doc->documentElement->lastChild; |
| 145 | +$target->before($doc->documentElement->firstChild, 'bar', $target); |
| 146 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 147 | + |
| 148 | + |
| 149 | +$doc = new \DOMDocument(); |
| 150 | +$doc->loadXML('<a>foo<last/></a>'); |
| 151 | +$target = $doc->documentElement->lastChild; |
| 152 | +$target->before($doc->documentElement->firstChild, $target, 'bar'); |
| 153 | +echo $doc->saveXML($doc->documentElement).PHP_EOL; |
| 154 | + |
| 155 | +?> |
| 156 | +--EXPECTF-- |
| 157 | +<a>foo<last/></a> |
| 158 | +<a>foo<last/></a> |
| 159 | +<a><last/>foo</a> |
| 160 | +<a>foo<last/></a> |
| 161 | +<a>foo<last/></a> |
| 162 | +<a><last/>foo</a> |
| 163 | +<a><last/>foo</a> |
| 164 | +<a>foo<last/></a> |
| 165 | +<a>barbazfoo<last/></a> |
| 166 | +<a>foobarbaz<last/></a> |
| 167 | +<a>foobarbaz<last/></a> |
| 168 | +<a>barfoobaz<last/></a> |
| 169 | +<a>barbazfoo<last/></a> |
| 170 | +<a>foo<last/>barbaz</a> |
| 171 | +<a>foobar<last/>baz</a> |
| 172 | +<a>foobarbaz<last/></a> |
| 173 | +<a>barfoo<last/></a> |
| 174 | +<a>foobar<last/></a> |
| 175 | +<a>foo<last/>bar</a> |
| 176 | +<a>barfoo<last/></a> |
| 177 | +<a>foobar<last/></a> |
| 178 | +<a>foo<last/>bar</a> |
0 commit comments