Composer/Pcre/Preg

This commit is contained in:
oleibman
2026-05-24 10:10:40 -07:00
parent 2b89a7bb7a
commit edec58eb59
2 changed files with 6 additions and 5 deletions
+4 -3
View File
@@ -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}"
+2 -2
View File
@@ -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');