From 39b573b29d5cace4b7eea4813e4ccf2b2dfec5cf Mon Sep 17 00:00:00 2001 From: Kirill Petrov Date: Wed, 26 Dec 2018 12:57:01 +0400 Subject: [PATCH] Fix infinite loop when reading invalid ODS files According to the spec, http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1415588_253892949, a `` can only ever contains a `` or a ``, but it seems that some invalid files in the wild may contains something else. That would trigger an infinite loop. So instead we totally ignore the invalid content. Closes #832 --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Reader/Ods.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed362653..e859fe9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). - Improved performance when loading large spreadsheets - [#825](https://github.com/PHPOffice/PhpSpreadsheet/pull/825) - Improved performance when loading large spreadsheets - [#824](https://github.com/PHPOffice/PhpSpreadsheet/pull/824) - Fix color from CSS when reading from HTML - [#831](https://github.com/PHPOffice/PhpSpreadsheet/pull/831) +- Fix infinite loop when reading invalid ODS files - [#832](https://github.com/PHPOffice/PhpSpreadsheet/pull/832) ## [1.5.2] - 2018-11-25 diff --git a/src/PhpSpreadsheet/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php index 2fb4b7f8..0941f035 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -210,6 +210,8 @@ class Ods extends BaseReader $mergeSize = $xml->getAttribute('table:number-columns-repeated'); $currCells += (int) $mergeSize; $xml->read(); + } else { + $xml->read(); } } while ($xml->name != 'table:table-row'); }