mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-18 22:16:46 +00:00
Composer/Pcre/Preg
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Shared;
|
||||
|
||||
use Composer\Pcre\Preg;
|
||||
use PhpOffice\PhpSpreadsheet\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException;
|
||||
use ZipArchive;
|
||||
@@ -144,9 +145,9 @@ class File
|
||||
public static function prohibitWrappers(string $filename): void
|
||||
{
|
||||
if (
|
||||
preg_match('~^phar://~i', $filename)
|
||||
|| (preg_match('/^([\w\s\x00-\x1f]+):/u', $filename) && !preg_match('/^([\w]+):/u', $filename))
|
||||
|| preg_match('~^php://.*phar:~i', $filename)
|
||||
Preg::IsMatch('~^phar://~i', $filename)
|
||||
|| (Preg::isMatch('/^([\w\s\x00-\x1f]+):/', $filename) && !Preg::isMatch('/^([\w]+):/', $filename))
|
||||
|| Preg::isMatch('~^php://.*phar:~i', $filename)
|
||||
) {
|
||||
throw new Exception(
|
||||
"Disallowed stream wrapper used for {$filename}"
|
||||
|
||||
@@ -119,8 +119,8 @@ class Drawing extends BaseDrawing
|
||||
// Check if a URL has been passed. https://stackoverflow.com/a/2058596/1252979
|
||||
} elseif (
|
||||
filter_var($path, FILTER_VALIDATE_URL)
|
||||
|| preg_match('~^phar://~i', $path)
|
||||
|| (preg_match('/^([\w\s\x00-\x1f]+):/u', $path) && !preg_match('/^([\w]+):/u', $path))
|
||||
|| Preg::isMatch('~^phar://~i', $path)
|
||||
|| (Preg::isMatch('/^([\w\s\x00-\x1f]+):/', $path) && !Preg::isMatch('/^([\w]+):/', $path))
|
||||
) {
|
||||
if (!Preg::isMatch('/^(http|https|file|ftp|s3):/', $path)) {
|
||||
throw new PhpSpreadsheetException('Invalid protocol for linked drawing');
|
||||
|
||||
Reference in New Issue
Block a user