1--TEST-- 2Phar: Phar::mount 3--SKIPIF-- 4<?php if (!extension_loaded("phar")) die("skip"); ?> 5--INI-- 6phar.readonly=0 7detect_unicode=0 8--FILE-- 9<?php 10$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; 11$pname = 'phar://' . $fname; 12$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar'; 13 14$a = new Phar($fname); 15$a['index.php'] = '<?php 16Phar::mount("testit", "' . addslashes(__FILE__) . '"); 17try { 18Phar::mount("testit", "' . addslashes(__FILE__) . '"); 19} catch (Exception $e) { 20echo $e->getMessage() . "\n"; 21} 22try { 23Phar::mount("' . addslashes($pname) . '/testit1", "' . addslashes(__FILE__) . '"); 24} catch (Exception $e) { 25echo $e->getMessage() . "\n"; 26} 27?>'; 28$a->setStub('<?php 29set_include_path("phar://" . __FILE__); 30include "index.php"; 31__HALT_COMPILER();'); 32Phar::mount($pname . '/testit1', __FILE__); 33include $fname; 34// test copying of a phar with mounted entries 35$b = $a->convertToExecutable(Phar::TAR); 36$b->setStub('<?php 37set_include_path("phar://" . __FILE__); 38include "index.php"; 39__HALT_COMPILER();'); 40try { 41include $fname2; 42} catch (Exception $e) { 43echo $e->getMessage(),"\n"; 44} 45try { 46Phar::mount($pname . '/oops', '/home/oops/../../etc/passwd:'); 47} catch (Exception $e) { 48echo $e->getMessage(),"\n"; 49} 50Phar::mount($pname . '/testit2', $pname . '/testit1'); 51echo substr($a['testit2']->getContent(),0, 50),"\n"; 52?> 53===DONE=== 54--CLEAN-- 55<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> 56<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?> 57--EXPECTF-- 58Mounting of testit to %sphar_mount.php within phar %sphar_mount.phar.php failed 59Can only mount internal paths within a phar archive, use a relative path instead of "phar://%sphar_mount.phar.php/testit1" 60Mounting of testit to %sphar_mount.php within phar %sphar_mount.phar.tar failed 61Mounting of /oops to /home/oops/../../etc/passwd: within phar %sphar_mount.phar.php failed 62<?php 63$fname = dirname(__FILE__) . '/' . basename( 64===DONE=== 65