1--TEST-- 2Phar: test edge cases of readfile() function interception 3--SKIPIF-- 4<?php if (!extension_loaded("phar")) die("skip");?> 5<?php if (version_compare(PHP_VERSION, "6.0", ">=")) die("skip requires php older than 6.0"); ?> 6--INI-- 7phar.readonly=0 8--FILE-- 9<?php 10Phar::interceptFileFuncs(); 11$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; 12$pname = 'phar://' . $fname; 13 14readfile(array()); 15chdir(dirname(__FILE__)); 16file_put_contents($fname, "blah\n"); 17file_put_contents("foob", "test\n"); 18readfile($fname); 19unlink($fname); 20mkdir($pname . '/oops'); 21file_put_contents($pname . '/foo/hi', '<?php 22readfile("foo/" . basename(__FILE__)); 23$context = stream_context_create(); 24readfile("foob"); 25set_include_path("' . addslashes(dirname(__FILE__)) . '"); 26readfile("foob", true); 27readfile("./hi", 0, $context); 28readfile("../oops"); 29?> 30'); 31include $pname . '/foo/hi'; 32?> 33===DONE=== 34--CLEAN-- 35<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> 36<?php rmdir(dirname(__FILE__) . '/poo'); ?> 37<?php unlink(dirname(__FILE__) . '/foob'); ?> 38--EXPECTF-- 39Warning: readfile() expects parameter 1 to be a valid path, array given in %sreadfile_edgecases.php on line %d 40blah 41<?php 42readfile("foo/" . basename(__FILE__)); 43$context = stream_context_create(); 44readfile("foob"); 45set_include_path("%stests"); 46readfile("foob", true); 47readfile("./hi", 0, $context); 48readfile("../oops"); 49?> 50test 51test 52<?php 53readfile("foo/" . basename(__FILE__)); 54$context = stream_context_create(); 55readfile("foob"); 56set_include_path("%stests"); 57readfile("foob", true); 58readfile("./hi", 0, $context); 59readfile("../oops"); 60?> 61 62Warning: 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 63===DONE=== 64