1--TEST-- 2Phar: copy() zip-based 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.zip.php'; 13$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar.php'; 14 15$pname = 'phar://'.$fname; 16$iname = '/file.txt'; 17$ename = '/error/..'; 18 19$p = new Phar($fname); 20 21try 22{ 23 $p['a'] = 'hi'; 24 $p->startBuffering(); 25 $p->copy('a', 'b'); 26 echo file_get_contents($p['b']->getPathName()); 27 $p->copy('b', 'c'); 28 $p->stopBuffering(); 29 echo file_get_contents($p['c']->getPathName()); 30 copy($fname, $fname2); 31 var_dump($p->isFileFormat(Phar::ZIP)); 32 $p->copy('a', $ename); 33} 34catch(Exception $e) 35{ 36 echo $e->getMessage() . "\n"; 37} 38ini_set('phar.readonly',1); 39$p2 = new Phar($fname2); 40var_dump($p2->isFileFormat(Phar::ZIP)); 41echo "\n"; 42echo 'a: ' , file_get_contents($p2['a']->getPathName()); 43echo 'b: ' ,file_get_contents($p2['b']->getPathName()); 44echo 'c: ' ,file_get_contents($p2['c']->getPathName()); 45?> 46===DONE=== 47--CLEAN-- 48<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?> 49<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar.php'); ?> 50--EXPECTF-- 51hihibool(true) 52file "/error/.." contains invalid characters upper directory reference, cannot be copied from "a" in phar %s 53bool(true) 54 55a: hib: hic: hi===DONE=== 56