xref: /php-src/ext/dom/tests/bug80268_2.phpt (revision 12a4b224)
1--TEST--
2Bug #80268 (loadHTML() truncates at NUL bytes)
3--EXTENSIONS--
4dom
5--SKIPIF--
6<?php
7if (LIBXML_VERSION < 20912) die('skip For libxml2 >= 2.9.12 only');
8?>
9--FILE--
10<?php
11$doc = new DOMDocument;
12$doc->loadHTML("<p>foo\0bar</p>");
13$html = $doc->saveHTML();
14var_dump(strpos($html, '<p>foo</p>') !== false);
15
16file_put_contents(__DIR__ . '/80268.html', "<p>foo\0bar</p>");
17$doc = new DOMDocument;
18$doc->loadHTMLFile(__DIR__ . '/80268.html');
19$html = $doc->saveHTML();
20var_dump(strpos($html, '<p>foo</p>') !== false);
21?>
22--CLEAN--
23<?php
24unlink(__DIR__ . '/80268.html');
25?>
26--EXPECTF--
27Warning: DOMDocument::loadHTML(): Char 0x0 out of allowed range in Entity, line: 1 in %s on line %d
28bool(false)
29
30Warning: DOMDocument::loadHTMLFile(): Char 0x0 out of allowed range in %s on line %d
31bool(false)
32