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/create_path_error.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/create_path_error.phpt')
-rw-r--r-- | ext/phar/tests/create_path_error.phpt | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/ext/phar/tests/create_path_error.phpt b/ext/phar/tests/create_path_error.phpt new file mode 100644 index 0000000..d3fc035 --- /dev/null +++ b/ext/phar/tests/create_path_error.phpt @@ -0,0 +1,62 @@ +--TEST-- +Phar: create with illegal path +--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; + +@unlink($fname); + +file_put_contents($pname . '/a.php?', "query"); +file_put_contents($pname . '/b.php?bla', "query"); + +var_dump(file_get_contents($pname . '/a.php')); +var_dump(file_get_contents($pname . '/b.php')); + +function error_handler($errno, $errmsg) +{ + echo "Error: $errmsg\n"; +} + +set_error_handler('error_handler'); + +$checks = array('/', '.', '../', 'a/..', 'a/', 'b//a.php'); +foreach($checks as $check) +{ + file_put_contents($pname . '/' . $check, "error"); +} + +$phar = new Phar($fname); +$checks = array("a\0"); +foreach($checks as $check) +{ + try + { + $phar[$check] = 'error'; + } + catch(Exception $e) + { + echo 'Exception: ' . $e->getMessage() . "\n"; + } +} + +?> +===DONE=== +--CLEAN-- +<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> +--EXPECTF-- +string(5) "query" +string(5) "query" +Error: file_put_contents(phar://%s//): failed to open stream: phar error: file "" in phar "%s" cannot be empty +Error: file_put_contents(phar://%s/.): failed to open stream: phar error: file "" in phar "%s" cannot be empty +Error: file_put_contents(phar://%s/../): failed to open stream: phar error: file "" in phar "%s" cannot be empty +Error: file_put_contents(phar://%s/a/..): failed to open stream: phar error: file "" in phar "%s" cannot be empty +Exception: Entry a does not exist and cannot be created: phar error: invalid path "a" contains illegal character +===DONE=== |