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