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