1--TEST-- 2Phar: create with illegal path 3--EXTENSIONS-- 4phar 5--INI-- 6phar.readonly=0 7phar.require_hash=1 8--FILE-- 9<?php 10 11$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php'; 12$pname = 'phar://' . $fname; 13 14@unlink($fname); 15 16file_put_contents($pname . '/a.php?', "query"); 17file_put_contents($pname . '/b.php?bla', "query"); 18 19var_dump(file_get_contents($pname . '/a.php')); 20var_dump(file_get_contents($pname . '/b.php')); 21 22function error_handler($errno, $errmsg) 23{ 24 echo "Error: $errmsg"; 25} 26 27set_error_handler('error_handler'); 28 29$count = 0; 30$checks = array( 31 '/', '.', '../', 'a/..', 'a/', 'b//a.php', 32 "Font\xE5\x84\xB7\xE9\xBB\x91pro.ttf", //two valid multi-byte characters 33 "\xF0\x9F\x98\x8D.ttf", // valid 4 byte char - smiling face with heart-shaped eyes 34 "Font\xE9\xBBpro.ttf", //Invalid multi-byte character - missing last byte 35 "Font\xBB\x91pro.ttf", //Invalid multi-byte character - missing first byte 36 "Font\xC0\xAFpro.ttf", //Invalid multi-byte character - invalid first byte 37 "Font\xF0\x80\x90\x90pro.ttf", //Invalid multi-byte character - surrogate pair code point 38 "\xFC\x81\x81\x81\x81pro.ttf", //RFC 3629 limited char points to 0000-10FFFF aka 5 byte utf-8 not valid 39); 40foreach($checks as $check) 41{ 42 $count++; 43 echo "$count:"; 44 file_put_contents($pname . '/' . $check, "error"); 45 echo "\n"; 46} 47 48$phar = new Phar($fname); 49$checks = array("a\0"); 50foreach($checks as $check) 51{ 52 try 53 { 54 $phar[$check] = 'error'; 55 } 56 catch (ValueError $e) 57 { 58 echo 'Exception: ' . $e->getMessage() . "\n"; 59 } 60} 61 62?> 63--CLEAN-- 64<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> 65--EXPECTF-- 66string(5) "query" 67string(5) "query" 681:Error: file_put_contents(phar://%s//): Failed to open stream: phar error: file "" in phar "%s" cannot be empty 692:Error: file_put_contents(phar://%s/.): Failed to open stream: phar error: file "" in phar "%s" cannot be empty 703:Error: file_put_contents(phar://%s/../): Failed to open stream: phar error: file "" in phar "%s" cannot be empty 714:Error: file_put_contents(phar://%s/a/..): Failed to open stream: phar error: file "" in phar "%s" cannot be empty 725: 736: 747: 758: 769:Error: file_put_contents(phar://%s): Failed to open stream: phar error: invalid path "%s" contains illegal character 7710:Error: file_put_contents(phar://%s): Failed to open stream: phar error: invalid path "%s" contains illegal character 7811:Error: file_put_contents(phar://%s): Failed to open stream: phar error: invalid path "%s" contains illegal character 7912:Error: file_put_contents(phar://%s): Failed to open stream: phar error: invalid path "%s" contains illegal character 8013:Error: file_put_contents(phar://%s): Failed to open stream: phar error: invalid path "%s" contains illegal character 81Exception: Phar::offsetSet(): Argument #1 ($localName) must not contain any null bytes 82