xref: /PHP-8.3/ext/phar/tests/invalid_alias.phpt (revision 98d004c9)
1--TEST--
2Phar: set alias with invalid alias containing / \ : or ;
3--EXTENSIONS--
4phar
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--EXPECTF--
36Invalid alias "hi/" specified for phar "%sinvalid_alias.phar"
37Invalid alias "hi\l" specified for phar "%sinvalid_alias.phar"
38Invalid alias "hil;" specified for phar "%sinvalid_alias.phar"
39Invalid alias ":hil" specified for phar "%sinvalid_alias.phar"
40