xref: /PHP-8.0/ext/phar/tests/invalid_alias.phpt (revision f8d79582)
1--TEST--
2Phar: set alias with invalid alias containing / \ : or ;
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.readonly=0
7--FILE--
8<?php
9$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar';
10
11$p = new Phar($fname);
12try {
13    $p->setAlias('hi/');
14} catch (Exception $e) {
15    echo $e->getMessage() . "\n";
16}
17try {
18    $p->setAlias('hi\\l');
19} catch (Exception $e) {
20    echo $e->getMessage() . "\n";
21}
22
23try {
24    $p->setAlias('hil;');
25} catch (Exception $e) {
26    echo $e->getMessage() . "\n";
27}
28
29try {
30    $p->setAlias(':hil');
31} catch (Exception $e) {
32    echo $e->getMessage() . "\n";
33}
34?>
35--CLEAN--
36<?php
37unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar');
38?>
39--EXPECTF--
40Invalid alias "hi/" specified for phar "%sinvalid_alias.phar"
41Invalid alias "hi\l" specified for phar "%sinvalid_alias.phar"
42Invalid alias "hil;" specified for phar "%sinvalid_alias.phar"
43Invalid alias ":hil" specified for phar "%sinvalid_alias.phar"
44