1
0
mirror of https://github.com/php/php-src.git synced 2026-04-04 22:52:40 +02:00
Files
archived-php-src/ext/phar/tests/phar_offset_get_error.phpt
Nikita Popov 7485978339 Migrate SKIPIF -> EXTENSIONS (#7138)
This is an automated migration of most SKIPIF extension_loaded checks.
2021-06-11 11:57:42 +02:00

49 lines
981 B
PHP

--TEST--
Phar: ignore filenames starting with / on offsetSet
--EXTENSIONS--
phar
--INI--
phar.readonly=0
phar.require_hash=1
--FILE--
<?php
$fname = __DIR__ . '/' . 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";
}
?>
--CLEAN--
<?php unlink(__DIR__ . '/' . 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