2007-02-04 13:21:40 +00:00
|
|
|
--TEST--
|
|
|
|
Phar: create with illegal path
|
|
|
|
--SKIPIF--
|
|
|
|
<?php if (!extension_loaded("phar")) print "skip"; ?>
|
|
|
|
<?php if (!extension_loaded("spl")) print "skip SPL not available"; ?>
|
|
|
|
--INI--
|
|
|
|
phar.readonly=0
|
|
|
|
phar.require_hash=1
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
|
|
|
|
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
|
|
|
|
$pname = 'phar://' . $fname;
|
|
|
|
|
|
|
|
@unlink($fname);
|
|
|
|
|
|
|
|
file_put_contents($pname . '/a.php?', "query");
|
|
|
|
file_put_contents($pname . '/b.php?bla', "query");
|
|
|
|
|
|
|
|
var_dump(file_get_contents($pname . '/a.php'));
|
|
|
|
var_dump(file_get_contents($pname . '/b.php'));
|
|
|
|
|
|
|
|
function error_handler($errno, $errmsg)
|
|
|
|
{
|
|
|
|
echo "Error: $errmsg\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
set_error_handler('error_handler');
|
|
|
|
|
2007-02-05 07:19:35 +00:00
|
|
|
$checks = array('/', '.', '../', 'a/..', 'a/', 'b//a.php');
|
2007-02-04 13:21:40 +00:00
|
|
|
foreach($checks as $check)
|
|
|
|
{
|
2007-02-05 07:19:35 +00:00
|
|
|
file_put_contents($pname . '/' . $check, "error");
|
2007-02-04 13:21:40 +00:00
|
|
|
}
|
|
|
|
|
2007-02-05 19:16:07 +00:00
|
|
|
$phar = new Phar($fname);
|
|
|
|
$checks = array("a\0");
|
|
|
|
foreach($checks as $check)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
$phar[$check] = 'error';
|
|
|
|
}
|
|
|
|
catch(Exception $e)
|
|
|
|
{
|
|
|
|
echo 'Exception: ' . $e->getMessage() . "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-04 13:21:40 +00:00
|
|
|
?>
|
|
|
|
===DONE===
|
|
|
|
--CLEAN--
|
|
|
|
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
|
|
|
|
--EXPECTF--
|
|
|
|
string(5) "query"
|
|
|
|
string(5) "query"
|
2007-02-05 07:19:35 +00:00
|
|
|
Error: file_put_contents(phar://%s//): failed to open stream: phar error: invalid path "/" contains empty directory
|
|
|
|
Error: file_put_contents(phar://%s/.): failed to open stream: phar error: invalid path "." contains current directory reference
|
|
|
|
Error: file_put_contents(phar://%s/../): failed to open stream: phar error: invalid path "../" contains empty directory
|
2007-02-04 13:21:40 +00:00
|
|
|
Error: file_put_contents(phar://%s/a/..): failed to open stream: phar error: invalid path "a/.." contains upper directory reference
|
2007-02-05 07:19:35 +00:00
|
|
|
Error: file_put_contents(phar://%s/a/): failed to open stream: phar error: invalid path "a/" contains empty directory
|
|
|
|
Error: file_put_contents(phar://%s/b//a.php): failed to open stream: phar error: invalid path "b//a.php" contains double slash
|
2007-02-05 19:16:07 +00:00
|
|
|
Exception: Entry a does not exist and cannot be created: phar error: invalid path "a" contains illegal character
|
2007-02-04 13:21:40 +00:00
|
|
|
===DONE===
|