mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-03 05:57:46 +00:00
More Tests
This commit is contained in:
@@ -147,7 +147,7 @@ class File
|
||||
if (
|
||||
Preg::IsMatch('~^phar://~i', $filename)
|
||||
|| (Preg::isMatch('/^([\w\s\x00-\x1f]+):/', $filename) && !Preg::isMatch('/^([\w]+):/', $filename))
|
||||
|| Preg::isMatch('~^php://.*phar:~i', $filename)
|
||||
|| Preg::isMatch('~^php://.*phar:~is', $filename)
|
||||
) {
|
||||
throw new Exception(
|
||||
"Disallowed stream wrapper used for {$filename}"
|
||||
|
||||
@@ -12,18 +12,6 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
class NoPharTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @param class-string<IReader> $reader
|
||||
*/
|
||||
#[DataProvider('providerReaders')]
|
||||
public function testNoPhar(string $reader): void
|
||||
{
|
||||
$this->expectException(SpreadsheetException::class);
|
||||
$this->expectExceptionMessage('Disallowed stream wrapper');
|
||||
$reader = new $reader();
|
||||
$reader->load('phar://anyoldname');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<IReader> $reader
|
||||
*/
|
||||
@@ -31,11 +19,14 @@ class NoPharTest extends TestCase
|
||||
public function testPhar3Slashes(string $reader): void
|
||||
{
|
||||
$invalidProtocol = [
|
||||
'normal phar' => 'phar://anyoldname',
|
||||
'3 slashes' => 'phar:///anyoldname',
|
||||
'mixed case' => 'Phar:///anyoldname',
|
||||
'embedded space' => 'ph ar://anyoldname',
|
||||
'leading space' => ' phar://anyoldname',
|
||||
'embedded control character' => "ph\x04ar://anyoldname",
|
||||
'filter with phar' => 'php://filter/read=convert.base64-encode/resource=phar:///tmp/x.Phar',
|
||||
'filter with phar and newline' => "php://filter/read=convert.base64-encode/\nresource=phar:///tmp/x.Phar",
|
||||
];
|
||||
$reader = new $reader();
|
||||
foreach ($invalidProtocol as $key => $value) {
|
||||
|
||||
Reference in New Issue
Block a user