Skip to content
This repository was archived by the owner on Jan 2, 2019. It is now read-only.

checking index exist as its throwing lot of errors for some of the ex… #755

Open
wants to merge 1 commit into
base: 1.8
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions Classes/PHPExcel/Reader/Excel5.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
const MS_BIFF_CRYPTO_NONE = 0;
const MS_BIFF_CRYPTO_XOR = 1;
const MS_BIFF_CRYPTO_RC4 = 2;

// Size of stream blocks when using RC4 encryption
const REKEY_BLOCK = 0x400;

Expand Down Expand Up @@ -382,7 +382,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
* @var int
*/
private $encryption = 0;

/**
* The position in the stream after which contents are encrypted
*
Expand Down Expand Up @@ -1221,7 +1221,7 @@ public function load($pFilename)

return $this->phpExcel;
}

/**
* Read record data from stream, decrypting as required
*
Expand All @@ -1234,12 +1234,12 @@ public function load($pFilename)
private function readRecordData($data, $pos, $len)
{
$data = substr($data, $pos, $len);

// File not encrypted, or record before encryption start point
if ($this->encryption == self::MS_BIFF_CRYPTO_NONE || $pos < $this->encryptionStartPos) {
return $data;
}

$recordData = '';
if ($this->encryption == self::MS_BIFF_CRYPTO_RC4) {
$oldBlock = floor($this->rc4Pos / self::REKEY_BLOCK);
Expand Down Expand Up @@ -1748,16 +1748,16 @@ private function readFilepass()
if ($length != 54) {
throw new PHPExcel_Reader_Exception('Unexpected file pass record length');
}

$recordData = $this->readRecordData($this->data, $this->pos + 4, $length);

// move stream pointer to next record
$this->pos += 4 + $length;

if (!$this->verifyPassword('VelvetSweatshop', substr($recordData, 6, 16), substr($recordData, 22, 16), substr($recordData, 38, 16), $this->md5Ctxt)) {
throw new PHPExcel_Reader_Exception('Decryption password incorrect');
}

$this->encryption = self::MS_BIFF_CRYPTO_RC4;

// Decryption required from the record after next onwards
Expand All @@ -1779,7 +1779,7 @@ private function makeKey($block, $valContext)
for ($i = 0; $i < 5; $i++) {
$pwarray[$i] = $valContext[$i];
}

$pwarray[5] = chr($block & 0xff);
$pwarray[6] = chr(($block >> 8) & 0xff);
$pwarray[7] = chr(($block >> 16) & 0xff);
Expand Down Expand Up @@ -1868,7 +1868,7 @@ private function verifyPassword($password, $docid, $salt_data, $hashedsalt_data,

$salt = $key->RC4($salt_data);
$hashedsalt = $key->RC4($hashedsalt_data);

$salt .= "\x80" . str_repeat("\0", 47);
$salt[56] = "\x80";

Expand Down Expand Up @@ -3541,7 +3541,9 @@ private function readColInfo()
$this->phpSheet->getColumnDimensionByColumn($i)->setVisible(!$isHidden);
$this->phpSheet->getColumnDimensionByColumn($i)->setOutlineLevel($level);
$this->phpSheet->getColumnDimensionByColumn($i)->setCollapsed($isCollapsed);
$this->phpSheet->getColumnDimensionByColumn($i)->setXfIndex($this->mapCellXfIndex[$xfIndex]);
if(!empty($this->mapCellXfIndex[$xfIndex])){
$this->phpSheet->getColumnDimensionByColumn($i)->setXfIndex($this->mapCellXfIndex[$xfIndex]);
}
}
}
}
Expand Down