1--TEST--
2Phar: test edge cases of readfile() function interception
3--EXTENSIONS--
4phar
5--INI--
6phar.readonly=0
7--FILE--
8<?php
9Phar::interceptFileFuncs();
10$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
11$pname = 'phar://' . $fname;
12
13chdir(__DIR__);
14file_put_contents($fname, "blah\n");
15file_put_contents("readfile_edgecases.txt", "test\n");
16readfile($fname);
17unlink($fname);
18mkdir($pname . '/oops');
19file_put_contents($pname . '/foo/hi', '<?php
20readfile("foo/" . basename(__FILE__));
21$context = stream_context_create();
22readfile("readfile_edgecases.txt");
23set_include_path("' . addslashes(__DIR__) . '");
24readfile("readfile_edgecases.txt", true);
25readfile("./hi", 0, $context);
26readfile("../oops");
27?>
28');
29include $pname . '/foo/hi';
30?>
31--CLEAN--
32<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
33<?php unlink(__DIR__ . '/readfile_edgecases.txt'); ?>
34--EXPECTF--
35blah
36<?php
37readfile("foo/" . basename(__FILE__));
38$context = stream_context_create();
39readfile("readfile_edgecases.txt");
40set_include_path("%stests");
41readfile("readfile_edgecases.txt", true);
42readfile("./hi", 0, $context);
43readfile("../oops");
44?>
45test
46test
47<?php
48readfile("foo/" . basename(__FILE__));
49$context = stream_context_create();
50readfile("readfile_edgecases.txt");
51set_include_path("%stests");
52readfile("readfile_edgecases.txt", true);
53readfile("./hi", 0, $context);
54readfile("../oops");
55?>
56
57Warning: readfile(phar://%sreadfile_edgecases.phar.php/oops): Failed to open stream: phar error: path "oops" is a directory in phar://%sreadfile_edgecases.phar.php/foo/hi on line %d
58