mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-22 08:09:15 +00:00
Fix PHP8.2 str_split function returns empty arrays for empty strings
This commit is contained in:
@@ -96,7 +96,7 @@ class ConvertHex extends ConvertBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
$binX = '';
|
$binX = '';
|
||||||
foreach (str_split($value) as $char) {
|
foreach (mb_str_split($value) as $char) {
|
||||||
$binX .= str_pad(base_convert($char, 16, 2), 4, '0', STR_PAD_LEFT);
|
$binX .= str_pad(base_convert($char, 16, 2), 4, '0', STR_PAD_LEFT);
|
||||||
}
|
}
|
||||||
if (strlen($binX) == 40 && $binX[0] == '1') {
|
if (strlen($binX) == 40 && $binX[0] == '1') {
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class ConvertOctal extends ConvertBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
$binX = '';
|
$binX = '';
|
||||||
foreach (str_split($value) as $char) {
|
foreach (mb_str_split($value) as $char) {
|
||||||
$binX .= str_pad(decbin((int) $char), 3, '0', STR_PAD_LEFT);
|
$binX .= str_pad(decbin((int) $char), 3, '0', STR_PAD_LEFT);
|
||||||
}
|
}
|
||||||
if (strlen($binX) == 30 && $binX[0] == '1') {
|
if (strlen($binX) == 30 && $binX[0] == '1') {
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class Arabic
|
|||||||
|
|
||||||
private static function strSplit(string $roman): array
|
private static function strSplit(string $roman): array
|
||||||
{
|
{
|
||||||
$rslt = str_split($roman);
|
$rslt = mb_str_split($roman);
|
||||||
|
|
||||||
return self::mollifyScrutinizer($rslt);
|
return self::mollifyScrutinizer($rslt);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,8 +60,7 @@ class Delimiter
|
|||||||
|
|
||||||
protected function countDelimiterValues(string $line, array $delimiterKeys): void
|
protected function countDelimiterValues(string $line, array $delimiterKeys): void
|
||||||
{
|
{
|
||||||
$splitString = str_split($line, 1);
|
$splitString = mb_str_split($line, 1);
|
||||||
if (is_array($splitString)) {
|
|
||||||
$distribution = array_count_values($splitString);
|
$distribution = array_count_values($splitString);
|
||||||
$countLine = array_intersect_key($distribution, $delimiterKeys);
|
$countLine = array_intersect_key($distribution, $delimiterKeys);
|
||||||
|
|
||||||
@@ -69,7 +68,6 @@ class Delimiter
|
|||||||
$this->counts[$delimiter][] = $countLine[$delimiter] ?? 0;
|
$this->counts[$delimiter][] = $countLine[$delimiter] ?? 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function infer(): ?string
|
public function infer(): ?string
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ class XmlScanner
|
|||||||
$xml = $this->toUtf8($xml);
|
$xml = $this->toUtf8($xml);
|
||||||
|
|
||||||
// Don't rely purely on libxml_disable_entity_loader()
|
// Don't rely purely on libxml_disable_entity_loader()
|
||||||
$pattern = '/\\0?' . implode('\\0?', /** @scrutinizer ignore-type */ str_split($this->pattern)) . '\\0?/';
|
$pattern = '/\\0?' . implode('\\0?', /** @scrutinizer ignore-type */ mb_str_split($this->pattern)) . '\\0?/';
|
||||||
|
|
||||||
if (preg_match($pattern, $xml)) {
|
if (preg_match($pattern, $xml)) {
|
||||||
throw new Reader\Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
|
throw new Reader\Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
|
||||||
|
|||||||
+1
-1
@@ -40,7 +40,7 @@ class ConditionalFormattingRuleExtension
|
|||||||
|
|
||||||
private function generateUuid(): string
|
private function generateUuid(): string
|
||||||
{
|
{
|
||||||
$chars = str_split('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx');
|
$chars = mb_str_split('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx');
|
||||||
|
|
||||||
foreach ($chars as $i => $char) {
|
foreach ($chars as $i => $char) {
|
||||||
if ($char === 'x') {
|
if ($char === 'x') {
|
||||||
|
|||||||
@@ -177,6 +177,6 @@ class DateFormatter
|
|||||||
|
|
||||||
private static function escapeQuotesCallback(array $matches): string
|
private static function escapeQuotesCallback(array $matches): string
|
||||||
{
|
{
|
||||||
return '\\' . implode('\\', /** @scrutinizer ignore-type */ str_split($matches[1]));
|
return '\\' . implode('\\', /** @scrutinizer ignore-type */ mb_str_split($matches[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,4 +24,5 @@ return [
|
|||||||
[-2147483648, '"ff80000000"'],
|
[-2147483648, '"ff80000000"'],
|
||||||
[2147483648, '"80000000"'],
|
[2147483648, '"80000000"'],
|
||||||
[2147483647, '"7fffffff"'],
|
[2147483647, '"7fffffff"'],
|
||||||
|
[0, '""'],
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -17,4 +17,5 @@ return [
|
|||||||
['#NUM!', '"37777777770"'], // too many digits
|
['#NUM!', '"37777777770"'], // too many digits
|
||||||
[536870911, '"3777777777"'], // highest positive
|
[536870911, '"3777777777"'], // highest positive
|
||||||
[-536870912, '"4000000000"'], // lowest negative
|
[-536870912, '"4000000000"'], // lowest negative
|
||||||
|
['0', '""'],
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -57,4 +57,8 @@ return [
|
|||||||
'#VALUE!',
|
'#VALUE!',
|
||||||
'WRONG',
|
'WRONG',
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
'',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user