fix: issue #1476 crash with numeric string value terminating with new line (#1481)

* fix: issue #1476 crash with numeric string value terminating with new line
* test: provided tests for issue #1476
This commit is contained in:
Gianni Genovesi 2020-05-23 12:49:54 +02:00 committed by GitHub
parent be415fab56
commit 7b1957f996
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 0 deletions

View File

@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Fix RATE, PRICE, XIRR, and XNPV Functions [#1456](https://github.com/PHPOffice/PhpSpreadsheet/pull/1456)
- Save Excel 2010+ functions properly in XLSX [#1461](https://github.com/PHPOffice/PhpSpreadsheet/pull/1461)
- Several improvements in HTML writer [#1464](https://github.com/PHPOffice/PhpSpreadsheet/pull/1464)
- Fix Crash while trying setting a cell the value "123456\n" [#1476](https://github.com/PHPOffice/PhpSpreadsheet/pull/1481)
### Changed

View File

@ -65,6 +65,8 @@ class DefaultValueBinder implements IValueBinder
return DataType::TYPE_STRING;
} elseif ((strpos($pValue, '.') === false) && ($pValue > PHP_INT_MAX)) {
return DataType::TYPE_STRING;
} elseif (!is_numeric($pValue)) {
return DataType::TYPE_STRING;
}
return DataType::TYPE_NUMERIC;

View File

@ -57,6 +57,7 @@ class DefaultValueBinderTest extends TestCase
['#REF!'],
[new DateTime()],
[new DateTimeImmutable()],
['123456\n'],
];
}

View File

@ -73,4 +73,8 @@ return [
'e',
'#DIV/0!',
],
[
's',
'123456\n',
],
];