Skip to content

Commit

Permalink
Allow php-cs-fixer to Handle Implicit Backslashes
Browse files Browse the repository at this point in the history
  • Loading branch information
oleibman committed Feb 11, 2025
1 parent 12c2e79 commit 99f5c18
Show file tree
Hide file tree
Showing 43 changed files with 110 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
'static_lambda' => false, // Risky if we can't guarantee nobody use `bindTo()`
'strict_comparison' => false, // No, too dangerous to change that
'strict_param' => 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
'string_length_to_empty' => true,
'string_line_ending' => true,
'switch_case_semicolon_to_colon' => true,
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org).

# TBD - 2.1.10

### Changed

- Allow php-cs-fixer to Handle Implicit Backslashes.

### Fixed

- TEXT and TIMEVALUE functions. [Issue #4249](https://github.com/PHPOffice/PhpSpreadsheet/issues/4249) [PR #4353](https://github.com/PHPOffice/PhpSpreadsheet/pull/4353)
Expand Down
4 changes: 2 additions & 2 deletions bin/findpolyfill.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ function findPolyfill(string $directory): int
// See issue #4215 - code which should have erred in unit test
// succeeded because a dev package required polyfills.
$retCode = 0;
$polyfill81 = 'MYSQLI_REFRESH_REPLICA\\b'
$polyfill81 = 'MYSQLI_REFRESH_REPLICA\b'
. '|fdiv[(]'
. '|array_is_list[(]'
. '|enum_exists[(]';
$polyfill = '/\\b(?:'
$polyfill = '/\b(?:'
. $polyfill81
. ')/';

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.0.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 @@ -50,7 +50,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
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 @@ -308,7 +308,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 @@ -56,7 +56,7 @@ public static function dataTypeForValue(mixed $value): string
return DataType::TYPE_INLINE;
} elseif (is_string($value) && strlen($value) > 1 && $value[0] === '=') {
return DataType::TYPE_FORMULA;
} elseif (preg_match('/^[\+\-]?(\d+\\.?\d*|\d*\\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $value)) {
} elseif (preg_match('/^[\+\-]?(\d+\.?\d*|\d*\.?\d+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $value)) {
$tValue = ltrim($value, '+-');
if (is_string($value) && 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
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Reader/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,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
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 @@ -358,7 +358,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 @@ -446,7 +446,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 = $matches[1] % 8; // @phpstan-ignore-line
$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 @@ -25,7 +25,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
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Shared/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,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 @@ -163,7 +163,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
6 changes: 3 additions & 3 deletions src/PhpSpreadsheet/Style/NumberFormat/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,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 @@ -141,7 +141,7 @@ public static function toFormattedString($value, string $format, ?array $callBac
$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
6 changes: 3 additions & 3 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 @@ -211,11 +211,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 Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Worksheet/AutoFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,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
6 changes: 3 additions & 3 deletions src/PhpSpreadsheet/Worksheet/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ public function setName(string $name): self
) {
throw new PhpSpreadsheetException('The table name can\'t be the same as a cell reference');
}
if (!preg_match('/^[\p{L}_\\\\]/iu', $name)) {
if (!preg_match('/^[\p{L}_\\\]/iu', $name)) {
throw new PhpSpreadsheetException('The table name must begin a name with a letter, an underscore character (_), or a backslash (\)');
}
if (!preg_match('/^[\p{L}_\\\\][\p{L}\p{M}0-9\._]+$/iu', $name)) {
if (!preg_match('/^[\p{L}_\\\][\p{L}\p{M}0-9\._]+$/iu', $name)) {
throw new PhpSpreadsheetException('The table name contains invalid characters');
}

Expand Down Expand Up @@ -317,7 +317,7 @@ public function setRangeToMaxRow(): self
{
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/Validations.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static function validateCellRange(AddressRange|string|array $cellRange):
// Convert Column ranges like 'A:C' to 'A1:C1048576'
// or Row ranges like '1:3' to 'A1:XFD3'
$addressRange = (string) preg_replace(
['/^([A-Z]+):([A-Z]+)$/i', '/^(\\d+):(\\d+)$/'],
['/^([A-Z]+):([A-Z]+)$/i', '/^(\d+):(\d+)$/'],
[self::SETMAXROW, self::SETMAXCOL],
$addressRange ?? ''
);
Expand Down
2 changes: 1 addition & 1 deletion src/PhpSpreadsheet/Worksheet/Worksheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -1700,7 +1700,7 @@ public function mergeCells(AddressRange|string|array $range, string $behaviour =
$range .= ":{$range}";
}

if (preg_match('/^([A-Z]+)(\\d+):([A-Z]+)(\\d+)$/', $range, $matches) !== 1) {
if (preg_match('/^([A-Z]+)(\d+):([A-Z]+)(\d+)$/', $range, $matches) !== 1) {
throw new Exception('Merge must be on a valid range of cells.');
}

Expand Down
10 changes: 5 additions & 5 deletions src/PhpSpreadsheet/Writer/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ private function generateRowCellData(Worksheet $worksheet, null|Cell|string $cel

// Converts the cell content so that spaces occuring at beginning of each new line are replaced by &nbsp;
// Example: " Hello\n to the world" is converted to "&nbsp;&nbsp;Hello\n&nbsp;to the world"
$cellData = Preg::replace('/(?m)(?:^|\\G) /', '&nbsp;', $cellData);
$cellData = Preg::replace('/(?m)(?:^|\G) /', '&nbsp;', $cellData);

// convert newline "\n" to '<br>'
$cellData = nl2br($cellData);
Expand Down Expand Up @@ -1496,8 +1496,8 @@ private function generateRow(Worksheet $worksheet, array $values, int $row, stri
if ($worksheet->hyperlinkExists($coordinate) && !$worksheet->getHyperlink($coordinate)->isInternal()) {
$url = $worksheet->getHyperlink($coordinate)->getUrl();
$urlDecode1 = html_entity_decode($url, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
$urlTrim = Preg::replace('/^\\s+/u', '', $urlDecode1);
$parseScheme = Preg::isMatch('/^([\\w\\s\\x00-\\x1f]+):/u', strtolower($urlTrim), $matches);
$urlTrim = Preg::replace('/^\s+/u', '', $urlDecode1);
$parseScheme = Preg::isMatch('/^([\w\s\x00-\x1f]+):/u', strtolower($urlTrim), $matches);
if ($parseScheme && !in_array($matches[1], ['http', 'https', 'file', 'ftp', 'mailto', 's3'], true)) {
$cellData = htmlspecialchars($url, Settings::htmlEntityFlags());
$cellData = self::replaceControlChars($cellData);
Expand Down Expand Up @@ -1550,7 +1550,7 @@ public static function replaceNonAscii(array $matches): string
private static function replaceControlChars(string $convert): string
{
return Preg::replaceCallback(
'/[\\x00-\\x1f]/',
'/[\x00-\x1f]/',
[self::class, 'replaceNonAscii'],
$convert
);
Expand Down Expand Up @@ -1642,7 +1642,7 @@ public function formatColor(string $value, string $format): string
$color = null; // initialize
$matches = [];

$color_regex = '/^\\[[a-zA-Z]+\\]/';
$color_regex = '/^\[[a-zA-Z]+\]/';
if (Preg::isMatch($color_regex, $format, $matches)) {
$color = str_replace(['[', ']'], '', $matches[0]); // @phpstan-ignore-line
$color = strtolower($color);
Expand Down
Loading

0 comments on commit 99f5c18

Please sign in to comment.