Skip to content

Commit

Permalink
Allow php-cs-fixer to Handle Implicit Backslashes
Browse files Browse the repository at this point in the history
Its defaults are to unescape within single quotes, and escape within double quotes and here-docs. Right now, it leaves everything as-is, which means our code is inconsistent and need not be. Further, although dealing with complex regular expressions will never be easy, I find it much easier to figure out what's going on when superfluous back-slashes are removed.

These changes were all made automatically using the "fix" script, so should be reliable. They, of course, pass all unit tests.
  • Loading branch information
oleibman committed Feb 8, 2025
1 parent 9d1ad14 commit 37b6ca4
Show file tree
Hide file tree
Showing 52 changed files with 127 additions and 126 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
'standardize_not_equals' => true,
'static_lambda' => false, // Risky if we can't guarantee nobody use `bindTo()`
'strict_comparison' => false, // No, too dangerous to change that
'string_implicit_backslashes' => false, // was escape_implicit_backslashes, too confusing
'string_implicit_backslashes' => ['single_quoted' => 'unescape', 'double_quoted' => 'escape', 'heredoc' => 'escape'], // was escape_implicit_backslashes
'strict_param' => false, // No, too dangerous to change that
'string_length_to_empty' => true,
'string_line_ending' => true,
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"platform": {
"php" : "8.1.99"
},
"process-timeout": 600,
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/Calculation.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Calculation
// Defined Names: Named Range of cells, or Named Formulae
const CALCULATION_REGEXP_DEFINEDNAME = '((([^\s,!&%^\/\*\+<>=-]*)|(\'(?:[^\']|\'[^!])+?\')|(\"(?:[^\"]|\"[^!])+?\"))!)?([_\p{L}][_\p{L}\p{N}\.]*)';
// Structured Reference (Fully Qualified and Unqualified)
const CALCULATION_REGEXP_STRUCTURED_REFERENCE = '([\p{L}_\\\\][\p{L}\p{N}\._]+)?(\[(?:[^\d\]+-])?)';
const CALCULATION_REGEXP_STRUCTURED_REFERENCE = '([\p{L}_\\\][\p{L}\p{N}\._]+)?(\[(?:[^\d\]+-])?)';
// Error
const CALCULATION_REGEXP_ERROR = '\#[A-Z][A-Z0_\/]*[!\?]?';

Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static function fromString(null|array|string|int|bool|float $dateValue):
}

// try to parse as date iff there is at least one digit
if (is_string($dateValue) && preg_match('/\\d/', $dateValue) !== 1) {
if (is_string($dateValue) && preg_match('/\d/', $dateValue) !== 1) {
return ExcelError::VALUE();
}

Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function fromString(null|array|string|int|bool|float $timeValue):
}

// try to parse as time iff there is at least one digit
if (is_string($timeValue) && preg_match('/\\d/', $timeValue) !== 1) {
if (is_string($timeValue) && preg_match('/\d/', $timeValue) !== 1) {
return ExcelError::VALUE();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class StructuredReference implements Operand, Stringable
self::ITEM_SPECIFIER_TOTALS,
];

private const TABLE_REFERENCE = '/([\p{L}_\\\\][\p{L}\p{N}\._]+)?(\[(?:[^\]\[]+|(?R))*+\])/miu';
private const TABLE_REFERENCE = '/([\p{L}_\\\][\p{L}\p{N}\._]+)?(\[(?:[^\]\[]+|(?R))*+\])/miu';

private string $value;

Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/FormulaParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ private function parseToTokens(): void
// scientific notation check
if (str_contains(self::OPERATORS_SN, $this->formula[$index])) {
if (strlen($value) > 1) {
if (preg_match('/^[1-9]{1}(\\.\\d+)?E{1}$/', $this->formula[$index]) != 0) {
if (preg_match('/^[1-9]{1}(\.\d+)?E{1}$/', $this->formula[$index]) != 0) {
$value .= $this->formula[$index];
++$index;

Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public static function expandDefinedName(string $coordinate, Cell $cell): string

public static function trimTrailingRange(string $coordinate): string
{
return (string) preg_replace('/:[\\w\$]+$/', '', $coordinate);
return (string) preg_replace('/:[\w\$]+$/', '', $coordinate);
}

public static function trimSheetFromCellReference(string $coordinate): string
Expand Down
8 changes: 4 additions & 4 deletions src/PhpSpreadsheet/Calculation/Internal/WildcardMatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ class WildcardMatch
{
private const SEARCH_SET = [
'~~', // convert double tilde to unprintable value
'~\\*', // convert tilde backslash asterisk to [*] (matches literal asterisk in regexp)
'\\*', // convert backslash asterisk to .* (matches string of any length in regexp)
'~\\?', // convert tilde backslash question to [?] (matches literal question mark in regexp)
'\\?', // convert backslash question to . (matches one character in regexp)
'~\*', // convert tilde backslash asterisk to [*] (matches literal asterisk in regexp)
'\*', // convert backslash asterisk to .* (matches string of any length in regexp)
'~\?', // convert tilde backslash question to [?] (matches literal question mark in regexp)
'\?', // convert backslash question to . (matches one character in regexp)
"\x1c", // convert original double tilde to single tilde
];

Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Calculation/TextData/Trim.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static function nonPrintable(mixed $stringValue = '')

$stringValue = Helpers::extractString($stringValue);

return (string) preg_replace('/[\\x00-\\x1f]/', '', "$stringValue");
return (string) preg_replace('/[\x00-\x1f]/', '', "$stringValue");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Cell/DefaultValueBinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static function dataTypeForValue(mixed $value): string

return DataType::TYPE_FORMULA;
}
if (preg_match('/^[\+\-]?(\d+\\.?\d*|\d*\\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $value)) {
if (preg_match('/^[\+\-]?(\d+\.?\d*|\d*\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $value)) {
$tValue = ltrim($value, '+-');
if (strlen($tValue) > 1 && $tValue[0] === '0' && $tValue[1] !== '.') {
return DataType::TYPE_STRING;
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Document/Properties.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ private static function intOrFloatTimestamp(null|bool|float|int|string $timestam
$timestamp = (float) $timestamp;
} else {
$timestamp = (string) preg_replace('/[.][0-9]*$/', '', $timestamp);
$timestamp = (string) preg_replace('/^(\\d{4})- (\\d)/', '$1-0$2', $timestamp);
$timestamp = (string) preg_replace('/^(\\d{4}-\\d{2})- (\\d)/', '$1-0$2', $timestamp);
$timestamp = (string) preg_replace('/^(\d{4})- (\d)/', '$1-0$2', $timestamp);
$timestamp = (string) preg_replace('/^(\d{4}-\d{2})- (\d)/', '$1-0$2', $timestamp);
$timestamp = (float) (new DateTime($timestamp))->format('U');
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Reader/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Html extends BaseReader

private const STARTS_WITH_BOM = '/^(?:\xfe\xff|\xff\xfe|\xEF\xBB\xBF)/';

private const DECLARES_CHARSET = '/\\bcharset=/i';
private const DECLARES_CHARSET = '/\bcharset=/i';

/**
* Input encoding.
Expand Down Expand Up @@ -373,7 +373,7 @@ private function processDomElementSpanEtc(Worksheet $sheet, int &$row, string &$
}
if (isset($attributeArray['style'])) {
$alignStyle = $attributeArray['style'];
if (preg_match('/\\btext-align:\\s*(left|right|center|justify)\\b/', $alignStyle, $matches) === 1) {
if (preg_match('/\btext-align:\s*(left|right|center|justify)\b/', $alignStyle, $matches) === 1) {
$sheet->getComment($column . $row)->setAlignment($matches[1]);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Reader/Ods/FormulaTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static function convertToExcelAddressValue(string $openOfficeAddress): st
'/\$?([^\.]+)\.([^\.]+)/miu', // Cell reference in another sheet
'/\.([^\.]+):\.([^\.]+)/miu', // Cell range reference
'/\.([^\.]+)/miu', // Simple cell reference
'/\\x{FFFE}/miu', // restore quoted periods
'/\x{FFFE}/miu', // restore quoted periods
],
[
'$1!$2:$4',
Expand Down Expand Up @@ -68,7 +68,7 @@ public static function convertToExcelFormulaValue(string $openOfficeFormula): st
'/\[\$?([^\.]+)\.([^\.]+)\]/miu', // Cell reference in another sheet
'/\[\.([^\.]+):\.([^\.]+)\]/miu', // Cell range reference
'/\[\.([^\.]+)\]/miu', // Simple cell reference
'/\\x{FFFE}/miu', // restore quoted periods
'/\x{FFFE}/miu', // restore quoted periods
],
[
'$1!$2:$3',
Expand Down
8 changes: 4 additions & 4 deletions src/PhpSpreadsheet/Reader/Security/XmlScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

class XmlScanner
{
private const ENCODING_PATTERN = '/encoding\\s*=\\s*(["\'])(.+?)\\1/s';
private const ENCODING_UTF7 = '/encoding\\s*=\\s*(["\'])UTF-7\\1/si';
private const ENCODING_PATTERN = '/encoding\s*=\s*(["\'])(.+?)\1/s';
private const ENCODING_UTF7 = '/encoding\s*=\s*(["\'])UTF-7\1/si';

private string $pattern;

Expand Down Expand Up @@ -41,7 +41,7 @@ private function toUtf8(string $xml): string
$charset = $this->findCharSet($xml);
$foundUtf7 = $charset === 'UTF-7';
if ($charset !== 'UTF-8') {
$testStart = '/^.{0,4}\\s*<?xml/s';
$testStart = '/^.{0,4}\s*<?xml/s';
$startWithXml1 = preg_match($testStart, $xml);
$xml = self::forceString(mb_convert_encoding($xml, 'UTF-8', $charset));
if ($startWithXml1 === 1 && preg_match($testStart, $xml) !== 1) {
Expand Down Expand Up @@ -87,7 +87,7 @@ private function findCharSet(string $xml): string
public function scan($xml): string
{
// Don't rely purely on libxml_disable_entity_loader()
$pattern = '/\\0*' . implode('\\0*', str_split($this->pattern)) . '\\0*/';
$pattern = '/\0*' . implode('\0*', str_split($this->pattern)) . '\0*/';

$xml = "$xml";
if (preg_match($pattern, $xml)) {
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Reader/Slk.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ private function styleSettings(string $rowDatum, array &$styleData, string &$fon
} elseif ($char == 'S') {
$styleData['fill']['fillType'] = Fill::FILL_PATTERN_GRAY125;
} elseif ($char == 'M') {
if (preg_match('/M([1-9]\\d*)/', $styleSettings, $matches)) {
if (preg_match('/M([1-9]\d*)/', $styleSettings, $matches)) {
$fontStyle = $matches[1];
}
}
Expand Down Expand Up @@ -449,7 +449,7 @@ private function processPRecord(array $rowData, Spreadsheet &$spreadsheet): void

private function processPColors(string $rowDatum, array &$formatArray): void
{
if (preg_match('/L([1-9]\\d*)/', $rowDatum, $matches)) {
if (preg_match('/L([1-9]\d*)/', $rowDatum, $matches)) {
$fontColor = ((int) $matches[1]) % 8;
$formatArray['font']['color']['argb'] = self::COLOR_ARRAY[$fontColor];
}
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function load(): void
$range = strtoupper((string) $dataValidation['sqref']);
$rangeSet = explode(' ', $range);
foreach ($rangeSet as $range) {
if (preg_match('/^[A-Z]{1,3}\\d{1,7}/', $range, $matches) === 1) {
if (preg_match('/^[A-Z]{1,3}\d{1,7}/', $range, $matches) === 1) {
// Ensure left/top row of range exists, thereby
// adjusting high row/column.
$this->worksheet->getCell($matches[0]);
Expand Down
4 changes: 2 additions & 2 deletions src/PhpSpreadsheet/Reader/Xml/DataValidations.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function loadDataValidations(SimpleXMLElement $worksheet, Spreadsheet $sp
$this->thisColumn = (int) $selectionMatches[2];
$combinedCells .= "$separator$cell";
$separator = ' ';
} elseif (preg_match('/^C(\d+)(:C(]\\d+))?$/', (string) $range, $selectionMatches) === 1) {
} elseif (preg_match('/^C(\d+)(:C(]\d+))?$/', (string) $range, $selectionMatches) === 1) {
// column
$firstCol = $selectionMatches[1];
$firstColString = Coordinate::stringFromColumnIndex((int) $firstCol);
Expand All @@ -95,7 +95,7 @@ public function loadDataValidations(SimpleXMLElement $worksheet, Spreadsheet $sp
$sheet->getCell($firstCell);
$combinedCells .= "$separator$cell";
$separator = ' ';
} elseif (preg_match('/^R(\\d+)(:R(]\\d+))?$/', (string) $range, $selectionMatches)) {
} elseif (preg_match('/^R(\d+)(:R(]\d+))?$/', (string) $range, $selectionMatches)) {
// row
$firstRow = $selectionMatches[1];
$lastRow = $selectionMatches[3] ?? $firstRow;
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Shared/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public static function convertIsoDate(mixed $value): float|int
throw new Exception("Invalid string $value supplied for datatype Date");
}

if (preg_match('/^\\s*\\d?\\d:\\d\\d(:\\d\\d([.]\\d+)?)?\\s*(am|pm)?\\s*$/i', $value) == 1) {
if (preg_match('/^\s*\d?\d:\d\d(:\d\d([.]\d+)?)?\s*(am|pm)?\s*$/i', $value) == 1) {
$newValue = fmod($newValue, 1.0);
}

Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Shared/Font.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ public static function getTrueTypeFontFileFromFont(FontStyle $font, bool $checkP
if (mb_strlen(self::$trueTypeFontPath) > 1 && mb_substr(self::$trueTypeFontPath, -1) !== '/' && mb_substr(self::$trueTypeFontPath, -1) !== '\\') {
$separator = DIRECTORY_SEPARATOR;
}
$fontFileAbsolute = preg_match('~^([A-Za-z]:)?[/\\\\]~', $fontFile) === 1;
$fontFileAbsolute = preg_match('~^([A-Za-z]:)?[/\\\]~', $fontFile) === 1;
if (!$fontFileAbsolute) {
$fontFile = self::findFontFile(self::$trueTypeFontPath, $fontFile) ?? self::$trueTypeFontPath . $separator . $fontFile;
}
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public static function format(mixed $value, string $format): string
// If the colon preceding minute had been quoted, as happens in
// Excel 2003 XML formats, m will not have been changed to i above.
// Change it now.
$format = (string) \preg_replace('/\\\\:m/', ':i', $format);
$format = (string) \preg_replace('/\\\:m/', ':i', $format);
$microseconds = (int) $dateObj->format('u');
if (str_contains($format, ':s.000')) {
$milliseconds = (int) round($microseconds / 1000.0);
Expand Down
10 changes: 5 additions & 5 deletions src/PhpSpreadsheet/Style/NumberFormat/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ private static function splitFormatForSectionSelection(array $sections, mixed $v
// 4 sections: [POSITIVE] [NEGATIVE] [ZERO] [TEXT]
$sectionCount = count($sections);
// Colour could be a named colour, or a numeric index entry in the colour-palette
$color_regex = '/\\[(' . implode('|', Color::NAMED_COLORS) . '|color\\s*(\\d+))\\]/mui';
$cond_regex = '/\\[(>|>=|<|<=|=|<>)([+-]?\\d+([.]\\d+)?)\\]/';
$color_regex = '/\[(' . implode('|', Color::NAMED_COLORS) . '|color\s*(\d+))\]/mui';
$cond_regex = '/\[(>|>=|<|<=|=|<>)([+-]?\d+([.]\d+)?)\]/';
$colors = ['', '', '', '', ''];
$conditionOperations = ['', '', '', '', ''];
$conditionComparisonValues = [0, 0, 0, 0, 0];
Expand Down Expand Up @@ -126,15 +126,15 @@ public static function toFormattedString($value, string $format, null|array|call
}
// For now we do not treat strings in sections, although section 4 of a format code affects strings
// Process a single block format code containing @ for text substitution
$formatx = str_replace('\\"', self::QUOTE_REPLACEMENT, $format);
$formatx = str_replace('\"', self::QUOTE_REPLACEMENT, $format);
if (preg_match(self::SECTION_SPLIT, $format) === 0 && preg_match(self::SYMBOL_AT, $formatx) === 1) {
if (!str_contains($format, '"')) {
return str_replace('@', $value, $format);
}
//escape any dollar signs on the string, so they are not replaced with an empty value
$value = str_replace(
['$', '"'],
['\\$', self::QUOTE_REPLACEMENT],
['\$', self::QUOTE_REPLACEMENT],
(string) $value
);

Expand All @@ -160,7 +160,7 @@ public static function toFormattedString($value, string $format, null|array|call
$format = (string) preg_replace('/^\[\$-[^\]]*\]/', '', $format);

$format = (string) preg_replace_callback(
'/(["])(?:(?=(\\\\?))\\2.)*?\\1/u',
'/(["])(?:(?=(\\\?))\2.)*?\1/u',
fn (array $matches): string => str_replace('.', chr(0x00), $matches[0]),
$format
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static function format(mixed $value, string $format): string
private static function getDecimal(string $value): string
{
$decimalPart = '0';
if (preg_match('/^\\d*[.](\\d*[1-9])0*$/', $value, $matches) === 1) {
if (preg_match('/^\d*[.](\d*[1-9])0*$/', $value, $matches) === 1) {
$decimalPart = $matches[1];
}

Expand Down
8 changes: 4 additions & 4 deletions src/PhpSpreadsheet/Style/NumberFormat/NumberFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class NumberFormatter extends BaseFormatter
{
private const NUMBER_REGEX = '/(0+)(\\.?)(0*)/';
private const NUMBER_REGEX = '/(0+)(\.?)(0*)/';

private static function mergeComplexNumberFormatMasks(array $numbers, array $masks): array
{
Expand Down Expand Up @@ -212,11 +212,11 @@ public static function format(mixed $value, string $format): string
$paddingPlaceholder = (str_contains($format, '?'));

// Replace # or ? with 0
$format = self::pregReplace('/[\\#\?](?=(?:[^"]*"[^"]*")*[^"]*\Z)/', '0', $format);
$format = self::pregReplace('/[\#\?](?=(?:[^"]*"[^"]*")*[^"]*\Z)/', '0', $format);
// Remove locale code [$-###] for an LCID
$format = self::pregReplace('/\[\$\-.*\]/', '', $format);

$n = '/\\[[^\\]]+\\]/';
$n = '/\[[^\]]+\]/';
$m = self::pregReplace($n, '', $format);

// Some non-number strings are quoted, so we'll get rid of the quotes, likewise any positional * symbols
Expand All @@ -236,7 +236,7 @@ public static function format(mixed $value, string $format): string

if (preg_match('/\[\$(.*)\]/u', $format, $m)) {
// Currency or Accounting
$value = preg_replace('/-0+(( |\\xc2\\xa0))?\\[/', '- [', (string) $value) ?? $value;
$value = preg_replace('/-0+(( |\xc2\xa0))?\[/', '- [', (string) $value) ?? $value;
$currencyCode = $m[1];
[$currencyCode] = explode('-', $currencyCode);
if ($currencyCode == '') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function format(): string
if ($symbolWithSpacing) {
$format .= '*' . $this->spaceOrNbsp;
}
if ($negativeStart === '\\(' || ($symbolWithSpacing && $negativeStart === '-')) {
if ($negativeStart === '\(' || ($symbolWithSpacing && $negativeStart === '-')) {
$format .= $negativeStart;
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ public function start(): string
{
return match ($this) {
self::minus, self::redMinus => '-',
self::parentheses, self::redParentheses => '\\(',
self::parentheses, self::redParentheses => '\(',
};
}

public function end(): string
{
return match ($this) {
self::minus, self::redMinus => '',
self::parentheses, self::redParentheses => '\\)',
self::parentheses, self::redParentheses => '\)',
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Worksheet/AutoFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function setRangeToMaxRow(): self
$this->evaluated = false;
if ($this->workSheet !== null) {
$thisrange = $this->range;
$range = (string) preg_replace('/\\d+$/', (string) $this->workSheet->getHighestRow(), $thisrange);
$range = (string) preg_replace('/\d+$/', (string) $this->workSheet->getHighestRow(), $thisrange);
if ($range !== $thisrange) {
$this->setRange($range);
}
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Worksheet/Drawing.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function setPath(string $path, bool $verifyFile = true, ?ZipArchive $zip

$this->path = '';
// Check if a URL has been passed. https://stackoverflow.com/a/2058596/1252979
if (filter_var($path, FILTER_VALIDATE_URL) || (preg_match('/^([\\w\\s\\x00-\\x1f]+):/u', $path) && !preg_match('/^([\\w]+):/u', $path))) {
if (filter_var($path, FILTER_VALIDATE_URL) || (preg_match('/^([\w\s\x00-\x1f]+):/u', $path) && !preg_match('/^([\w]+):/u', $path))) {
if (!preg_match('/^(http|https|file|ftp|s3):/', $path)) {
throw new PhpSpreadsheetException('Invalid protocol for linked drawing');
}
Expand Down
Loading

0 comments on commit 37b6ca4

Please sign in to comment.