Skip to content

Commit fa1965b

Browse files
committed
Restore tests
1 parent 3a3c502 commit fa1965b

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

ext/dom/tests/bug43364.phpt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--TEST--
2+
Bug #43364 (recursive xincludes don't remove internal xml nodes properly)
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
function loopElements($nodes)
8+
{
9+
$count = 0;
10+
foreach($nodes as $node) {
11+
if($node instanceof DOMElement) {
12+
$count++;
13+
if($node->childNodes->length > 0) {
14+
$count += loopElements($node->childNodes);
15+
}
16+
}
17+
}
18+
return $count;
19+
}
20+
21+
$xml = <<<DOC
22+
<?xml version="1.0" encoding="UTF-8"?>
23+
<root xmlns:xi="http://www.w3.org/2001/XInclude">
24+
<a>
25+
<a_child1>ac1</a_child1>
26+
<a_child2>ac2</a_child2>
27+
</a>
28+
<b><xi:include xpointer="xpointer(/root/a)" /></b>
29+
<c><xi:include xpointer="xpointer(/root/b)" /></c>
30+
</root>
31+
DOC;
32+
33+
$doc = new DomDocument();
34+
$doc->loadXml($xml);
35+
$doc->xinclude();
36+
37+
$count = loopElements(array($doc->documentElement));
38+
39+
var_dump($count);
40+
?>
41+
--EXPECT--
42+
int(13)

ext/dom/tests/bug80268.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Bug #80268 (loadHTML() truncates at NUL bytes)
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
$doc = new DOMDocument;
8+
$doc->loadHTML("<p>foo\0bar</p>");
9+
$html = $doc->saveHTML();
10+
var_dump(strpos($html, '<p>foo</p>') !== false);
11+
12+
file_put_contents(__DIR__ . '/80268.html', "<p>foo\0bar</p>");
13+
$doc = new DOMDocument;
14+
$doc->loadHTMLFile(__DIR__ . '/80268.html');
15+
$html = $doc->saveHTML();
16+
var_dump(strpos($html, '<p>foo</p>') !== false);
17+
?>
18+
--CLEAN--
19+
<?php
20+
unlink(__DIR__ . '/80268.html');
21+
?>
22+
--EXPECT--
23+
bool(true)
24+
bool(true)

0 commit comments

Comments
 (0)