Annotation of embedaddon/php/ext/phar/tests/create_path_error.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Phar: create with illegal path
                      3: --SKIPIF--
                      4: <?php if (!extension_loaded("phar")) die("skip"); ?>
                      5: <?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
                      6: --INI--
                      7: phar.readonly=0
                      8: phar.require_hash=1
                      9: --FILE--
                     10: <?php
                     11: 
                     12: $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
                     13: $pname = 'phar://' . $fname;
                     14: 
                     15: @unlink($fname);
                     16: 
                     17: file_put_contents($pname . '/a.php?', "query");
                     18: file_put_contents($pname . '/b.php?bla', "query");
                     19: 
                     20: var_dump(file_get_contents($pname . '/a.php'));
                     21: var_dump(file_get_contents($pname . '/b.php'));
                     22: 
                     23: function error_handler($errno, $errmsg)
                     24: {
                     25:        echo "Error: $errmsg\n";
                     26: }
                     27: 
                     28: set_error_handler('error_handler');
                     29: 
                     30: $checks = array('/', '.', '../', 'a/..', 'a/', 'b//a.php');
                     31: foreach($checks as $check)
                     32: {
                     33:        file_put_contents($pname . '/' . $check, "error");
                     34: }
                     35: 
                     36: $phar = new Phar($fname);
                     37: $checks = array("a\0");
                     38: foreach($checks as $check)
                     39: {
                     40:        try
                     41:        {
                     42:                $phar[$check] = 'error';
                     43:        }
                     44:        catch(Exception $e)
                     45:        {
                     46:                echo 'Exception: ' . $e->getMessage() . "\n";
                     47:        }
                     48: }
                     49: 
                     50: ?>
                     51: ===DONE===
                     52: --CLEAN--
                     53: <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
                     54: --EXPECTF--
                     55: string(5) "query"
                     56: string(5) "query"
                     57: Error: file_put_contents(phar://%s//): failed to open stream: phar error: file "" in phar "%s" cannot be empty
                     58: Error: file_put_contents(phar://%s/.): failed to open stream: phar error: file "" in phar "%s" cannot be empty
                     59: Error: file_put_contents(phar://%s/../): failed to open stream: phar error: file "" in phar "%s" cannot be empty
                     60: Error: file_put_contents(phar://%s/a/..): failed to open stream: phar error: file "" in phar "%s" cannot be empty
                     61: Exception: Entry a does not exist and cannot be created: phar error: invalid path "a" contains illegal character
                     62: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>