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