mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-31 20:49:55 +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 = '';
|
||||
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);
|
||||
}
|
||||
if (strlen($binX) == 40 && $binX[0] == '1') {
|
||||
|
||||
@@ -96,7 +96,7 @@ class ConvertOctal extends ConvertBase
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
if (strlen($binX) == 30 && $binX[0] == '1') {
|
||||
|
||||
@@ -60,7 +60,7 @@ class Arabic
|
||||
|
||||
private static function strSplit(string $roman): array
|
||||
{
|
||||
$rslt = str_split($roman);
|
||||
$rslt = mb_str_split($roman);
|
||||
|
||||
return self::mollifyScrutinizer($rslt);
|
||||
}
|
||||
|
||||
@@ -60,14 +60,12 @@ class Delimiter
|
||||
|
||||
protected function countDelimiterValues(string $line, array $delimiterKeys): void
|
||||
{
|
||||
$splitString = str_split($line, 1);
|
||||
if (is_array($splitString)) {
|
||||
$distribution = array_count_values($splitString);
|
||||
$countLine = array_intersect_key($distribution, $delimiterKeys);
|
||||
$splitString = mb_str_split($line, 1);
|
||||
$distribution = array_count_values($splitString);
|
||||
$countLine = array_intersect_key($distribution, $delimiterKeys);
|
||||
|
||||
foreach (self::POTENTIAL_DELIMETERS as $delimiter) {
|
||||
$this->counts[$delimiter][] = $countLine[$delimiter] ?? 0;
|
||||
}
|
||||
foreach (self::POTENTIAL_DELIMETERS as $delimiter) {
|
||||
$this->counts[$delimiter][] = $countLine[$delimiter] ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ class XmlScanner
|
||||
$xml = $this->toUtf8($xml);
|
||||
|
||||
// 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)) {
|
||||
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
|
||||
{
|
||||
$chars = str_split('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx');
|
||||
$chars = mb_str_split('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx');
|
||||
|
||||
foreach ($chars as $i => $char) {
|
||||
if ($char === 'x') {
|
||||
|
||||
@@ -177,6 +177,6 @@ class DateFormatter
|
||||
|
||||
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, '"80000000"'],
|
||||
[2147483647, '"7fffffff"'],
|
||||
[0, '""'],
|
||||
];
|
||||
|
||||
@@ -17,4 +17,5 @@ return [
|
||||
['#NUM!', '"37777777770"'], // too many digits
|
||||
[536870911, '"3777777777"'], // highest positive
|
||||
[-536870912, '"4000000000"'], // lowest negative
|
||||
['0', '""'],
|
||||
];
|
||||
|
||||
@@ -57,4 +57,8 @@ return [
|
||||
'#VALUE!',
|
||||
'WRONG',
|
||||
],
|
||||
[
|
||||
0,
|
||||
'',
|
||||
],
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user