1--TEST--
2Phar: ignore filenames starting with / on offsetSet
3--EXTENSIONS--
4phar
5--INI--
6phar.readonly=0
7phar.require_hash=1
8--FILE--
9<?php
10
11$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
12$pname = 'phar://'.$fname;
13$iname = '/file.txt';
14$ename = '/error/..';
15
16$p = new Phar($fname);
17$p[$iname] = "foobar\n";
18
19try
20{
21    $p[$ename] = "foobar\n";
22}
23catch(Exception $e)
24{
25    echo $e->getMessage() . "\n";
26}
27
28include($pname . $iname);
29
30// extra coverage
31try {
32$p['.phar/oops'] = 'hi';
33} catch (Exception $e) {
34echo $e->getMessage(),"\n";
35}
36try {
37$a = $p['.phar/stub.php'];
38} catch (Exception $e) {
39echo $e->getMessage(),"\n";
40}
41?>
42--CLEAN--
43<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
44--EXPECT--
45Entry /error/.. does not exist and cannot be created: phar error: invalid path "/error/.." contains upper directory reference
46foobar
47Cannot set any files or directories in magic ".phar" directory
48Entry .phar/stub.php does not exist
49