From 69bbad0c2271668d74595dadbd2df861184fe5b6 Mon Sep 17 00:00:00 2001 From: Gianni Genovesi Date: Wed, 20 May 2020 22:31:43 +0200 Subject: [PATCH 1/5] fix: issue #1476 crash with numeric string value terminating with new line --- src/PhpSpreadsheet/Cell/DefaultValueBinder.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PhpSpreadsheet/Cell/DefaultValueBinder.php b/src/PhpSpreadsheet/Cell/DefaultValueBinder.php index 3a676c4f89..693446e698 100644 --- a/src/PhpSpreadsheet/Cell/DefaultValueBinder.php +++ b/src/PhpSpreadsheet/Cell/DefaultValueBinder.php @@ -65,6 +65,8 @@ public static function dataTypeForValue($pValue) 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; From b3015c4973095e728234759d794e733611dcc9b8 Mon Sep 17 00:00:00 2001 From: Gianni Genovesi Date: Wed, 20 May 2020 22:37:35 +0200 Subject: [PATCH 2/5] fix: issue #1476 crash with numeric string value terminating with new line --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27d72197f3..254076d333 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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/issues/1476) ### Changed From 5ab231e65a0a30aa4d59c782a28a747973136f98 Mon Sep 17 00:00:00 2001 From: Gianni Genovesi Date: Wed, 20 May 2020 22:40:27 +0200 Subject: [PATCH 3/5] fix: issue #1476 crash with numeric string value terminating with new line --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 254076d333..eb9b381036 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +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/issues/1476) +- Fix Crash while trying setting a cell the value "123456\n" [#1476](https://github.com/PHPOffice/PhpSpreadsheet/pull/1481) ### Changed From e093ff88ec0553e0b95f2296df0a87d2102bc3cf Mon Sep 17 00:00:00 2001 From: Gianni Genovesi Date: Sat, 23 May 2020 10:13:19 +0200 Subject: [PATCH 4/5] test: provided tests for issue #1476 --- tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php | 1 + tests/data/Cell/DefaultValueBinder.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php b/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php index 90dabce3f1..42e1bb0533 100644 --- a/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php +++ b/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php @@ -57,6 +57,7 @@ public function binderProvider() ['#REF!'], [new DateTime()], [new DateTimeImmutable()], + ['123456\n'] ]; } diff --git a/tests/data/Cell/DefaultValueBinder.php b/tests/data/Cell/DefaultValueBinder.php index 53ba628190..1f0c40e06d 100644 --- a/tests/data/Cell/DefaultValueBinder.php +++ b/tests/data/Cell/DefaultValueBinder.php @@ -73,4 +73,8 @@ 'e', '#DIV/0!', ], + [ + 's', + '123456\n', + ], ]; From eb18b3376cc50cd7e5b5902e33edff1cd8c064a9 Mon Sep 17 00:00:00 2001 From: Gianni Genovesi Date: Sat, 23 May 2020 11:30:20 +0200 Subject: [PATCH 5/5] style: missing terminal comma in array list --- tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php b/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php index 42e1bb0533..e13cd9424b 100644 --- a/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php +++ b/tests/PhpSpreadsheetTests/Cell/DefaultValueBinderTest.php @@ -57,7 +57,7 @@ public function binderProvider() ['#REF!'], [new DateTime()], [new DateTimeImmutable()], - ['123456\n'] + ['123456\n'], ]; }