xref: /PHP-7.4/ext/simplexml/tests/bug79971_1.phpt (revision f15f8fc5)
1--TEST--
2Bug #79971 (special character is breaking the path in xml function)
3--SKIPIF--
4<?php
5if (!extension_loaded('simplexml')) die('skip simplexml extension not available');
6?>
7--FILE--
8<?php
9if (PHP_OS_FAMILY === 'Windows') {
10    $path = '/' . str_replace('\\', '/', __DIR__);
11} else {
12    $path = __DIR__;
13}
14$uri = "file://$path/bug79971_1.xml";
15var_dump(simplexml_load_file("$uri%00foo"));
16
17$sxe = simplexml_load_file($uri);
18var_dump($sxe->asXML("$uri.out%00foo"));
19?>
20--EXPECTF--
21Warning: simplexml_load_file(): URI must not contain percent-encoded NUL bytes in %s on line %d
22
23Warning: simplexml_load_file(): I/O warning : failed to load external entity "%s/bug79971_1.xml%00foo" in %s on line %d
24bool(false)
25
26Warning: SimpleXMLElement::asXML(): URI must not contain percent-encoded NUL bytes in %s on line %d
27bool(false)
28