mirror of
https://github.com/php/php-src.git
synced 2024-10-19 15:34:25 +00:00
de5aaaa74c
which then allows easy creation of tar/zip-based phar archives with a simple rename even when phar.readonly=1. Plug the hole very tightly, allowing read access to files, and also excluding them from opendir() output
52 lines
1.1 KiB
PHP
Executable File
52 lines
1.1 KiB
PHP
Executable File
--TEST--
|
|
Phar: ignore filenames starting with / on offsetSet
|
|
--SKIPIF--
|
|
<?php if (!extension_loaded("phar")) die("skip"); ?>
|
|
<?php if (!extension_loaded("spl")) die("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;
|
|
$iname = '/file.txt';
|
|
$ename = '/error/..';
|
|
|
|
$p = new Phar($fname);
|
|
$p[$iname] = "foobar\n";
|
|
|
|
try
|
|
{
|
|
$p[$ename] = "foobar\n";
|
|
}
|
|
catch(Exception $e)
|
|
{
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
|
|
include($pname . $iname);
|
|
|
|
// extra coverage
|
|
try {
|
|
$p['.phar/oops'] = 'hi';
|
|
} catch (Exception $e) {
|
|
echo $e->getMessage(),"\n";
|
|
}
|
|
try {
|
|
$a = $p['.phar/stub.php'];
|
|
} catch (Exception $e) {
|
|
echo $e->getMessage(),"\n";
|
|
}
|
|
?>
|
|
===DONE===
|
|
--CLEAN--
|
|
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
|
|
--EXPECT--
|
|
Entry /error/.. does not exist and cannot be created: phar error: invalid path "/error/.." contains upper directory reference
|
|
foobar
|
|
Cannot set any files or directories in magic ".phar" directory
|
|
Entry .phar/stub.php does not exist
|
|
===DONE===
|