diff options
| author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
|---|---|---|
| committer | <> | 2013-04-03 16:25:08 +0000 |
| commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
| tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/phar/tests/phar_offset_check.phpt | |
| download | php2-master.tar.gz | |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/phar/tests/phar_offset_check.phpt')
| -rw-r--r-- | ext/phar/tests/phar_offset_check.phpt | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/ext/phar/tests/phar_offset_check.phpt b/ext/phar/tests/phar_offset_check.phpt new file mode 100644 index 0000000..fe12534 --- /dev/null +++ b/ext/phar/tests/phar_offset_check.phpt @@ -0,0 +1,78 @@ +--TEST-- +Phar: disallow stub and alias setting via offset*() methods +--SKIPIF-- +<?php if (!extension_loaded("phar")) die("skip"); ?> +<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?> +--INI-- +phar.readonly=0 +phar.require_hash=1 +--FILE-- +<?php + +$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; +$pname = 'phar://'.$fname; + +$phar = new Phar($fname); +$phar->setDefaultStub(); +$phar->setAlias('susan'); +$phar['a.txt'] = "first file\n"; +$phar['b.txt'] = "second file\n"; + +try { + $phar->offsetGet('.phar/stub.php'); +} catch (Exception $e) { + echo $e->getMessage()."\n"; +} + +try { + $phar->offsetGet('.phar/alias.txt'); +} catch (Exception $e) { + echo $e->getMessage()."\n"; +} + +try { + $phar->offsetSet('.phar/stub.php', '<?php __HALT_COMPILER(); ?>'); +} catch (Exception $e) { + echo $e->getMessage()."\n"; +} + +var_dump(strlen($phar->getStub())); + +try { + $phar->offsetUnset('.phar/stub.php'); +} catch (Exception $e) { + echo $e->getMessage()."\n"; +} + +var_dump(strlen($phar->getStub())); + +try { + $phar->offsetSet('.phar/alias.txt', 'dolly'); +} catch (Exception $e) { + echo $e->getMessage()."\n"; +} + +var_dump($phar->getAlias()); + +try { + $phar->offsetUnset('.phar/alias.txt'); +} catch (Exception $e) { + echo $e->getMessage()."\n"; +} + +var_dump($phar->getAlias()); + +?> +===DONE=== +--CLEAN-- +<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> +--EXPECTF-- +Entry .phar/stub.php does not exist +Entry .phar/alias.txt does not exist +Cannot set stub ".phar/stub.php" directly in phar "%sphar_offset_check.phar.php", use setStub +int(6685) +int(6685) +Cannot set alias ".phar/alias.txt" directly in phar "%sphar_offset_check.phar.php", use setAlias +string(5) "susan" +string(5) "susan" +===DONE=== |
