summaryrefslogtreecommitdiff
path: root/ext/phar/tests/bug64931/bug64931.phpt
blob: 9c1f9dcaf1da5a53e306fe42a8eec52d916a8303 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
--TEST--
Bug #64931 (phar_add_file is too restrictive on filename)
--SKIPIF--
<?php extension_loaded("phar") or die("skip need ext/phar support"); ?>
--INI--
phar.readonly=0
--FILE--
<?php 

echo "Test\n";

@unlink(__DIR__."/bug64931.phar");
$phar = new Phar(__DIR__."/bug64931.phar");
$phar->addFile(__DIR__."/src/.pharignore", ".pharignore");
try {
	$phar->addFile(__DIR__."/src/.pharignore", ".phar/gotcha");
} catch (Exception $e) {
	echo "CAUGHT: ". $e->getMessage() ."\n";
}

try {
	$phar->addFromString(".phar", "gotcha");
} catch (Exception $e) {
	echo "CAUGHT: ". $e->getMessage() ."\n";
}

try {
	$phar->addFromString(".phar//", "gotcha");
} catch (Exception $e) {
	echo "CAUGHT: ". $e->getMessage() ."\n";
}

try {
	$phar->addFromString(".phar\\", "gotcha");
} catch (Exception $e) {
	echo "CAUGHT: ". $e->getMessage() ."\n";
}

try {
	$phar->addFromString(".phar\0", "gotcha");
} catch (Exception $e) {
	echo "CAUGHT: ". $e->getMessage() ."\n";
}

?>
===DONE===
--CLEAN--
<?php
@unlink(__DIR__."/bug64931.phar");
?>
--EXPECT--
Test
CAUGHT: Cannot create any files in magic ".phar" directory
CAUGHT: Cannot create any files in magic ".phar" directory
CAUGHT: Cannot create any files in magic ".phar" directory
CAUGHT: Cannot create any files in magic ".phar" directory
CAUGHT: Cannot create any files in magic ".phar" directory
===DONE===