Skip to content

Commit

Permalink
Bugfix for issue: xls file cause the exception during open by Xls rea…
Browse files Browse the repository at this point in the history
…der PHPOffice#402

 revert commit 4b4831b with adding exceptions
  • Loading branch information
bayzhanov committed Oct 2, 2018
1 parent d77841b commit 5ce0e96
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions src/PhpSpreadsheet/Shared/OLERead.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,11 @@ private function readPropertySets()
// type of entry
$type = ord($d[self::TYPE_POS]);

try {
// sectorID of first sector or short sector, if this entry refers to a stream (the case with workbook)
// sectorID of first sector of the short-stream container stream, if this entry is root entry
$startBlock = self::getInt4d($d, self::START_BLOCK_POS);

$size = self::getInt4d($d, self::SIZE_POS);
} catch (ReaderException $e) {
// skip invalid parameters, break loop
break;
}
// sectorID of first sector or short sector, if this entry refers to a stream (the case with workbook)
// sectorID of first sector of the short-stream container stream, if this entry is root entry
$startBlock = self::getInt4d($d, self::START_BLOCK_POS);

$size = self::getInt4d($d, self::SIZE_POS);

$name = str_replace("\x00", '', substr($d, 0, $nameSize));

Expand Down Expand Up @@ -331,14 +326,6 @@ private function readPropertySets()
*/
private static function getInt4d($data, $pos)
{
if (trim($data) == '') {
// No data provided
throw new ReaderException('Parameter data is empty.');
} elseif ($pos < 0) {
// Invalid position
throw new ReaderException('Parameter pos=' . $pos . ' is invalid.');
}

$len = strlen($data);
if ($len < $pos + 4) {
$data .= str_repeat("\0", $pos + 4 - $len);
Expand Down

0 comments on commit 5ce0e96

Please sign in to comment.