Skip to content

Fix for bug #1592 (UPDATED) #1623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 53 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
b3c2881
Fix for Xls when BIFF8 SST (FCh) has bad Shared string length
Aug 18, 2020
fa6b2de
Fix and test for bug #1592
Aug 18, 2020
07c16e9
Fix SST global limit count and improved bug test
Aug 21, 2020
5c22971
Fix SST global limit count and improved bug test
Aug 21, 2020
ae6c285
Calculation/DateTime Failure With PHP8 (#1661)
oleibman Oct 1, 2020
91cdec8
Reader/Gnumeric Failure with PHP8 (#1662)
oleibman Oct 1, 2020
98b81f1
ReverseSort bug, exposed but not caused by PHP8 (#1660)
oleibman Oct 2, 2020
c000815
Drop $this->spreadSheet null check from Xlsx Writer (#1646)
simPod Oct 2, 2020
8a9dbce
Update index.md (#1620)
Arman-Hosseini Oct 2, 2020
69c6135
Bug setting Superscript/Subscript to false (#1567)
oleibman Oct 5, 2020
a509ec4
Update CHANGELOG
PowerKiKi Oct 5, 2020
0b2c2e1
Sync README
PowerKiKi Oct 5, 2020
d87d8c8
fixed php8 deprecation warning for libxml_disable_entity_loader() (#1…
brainfoolong Oct 8, 2020
ed8bf9b
Switch from using poser badges to shields.io because poser wasn't pic…
Oct 9, 2020
30dffc3
Introduce GitHub Actions
PowerKiKi Oct 10, 2020
80bdfea
Annotate problems in code
PowerKiKi Oct 10, 2020
c6e4979
Publish API docs via GitHub Actions
PowerKiKi Oct 11, 2020
5799fee
Starting from scratch again: PHP8 nightly build included in test run,…
Aug 9, 2020
1781e24
xdebug isn't built into the nightly PHP, so we'll get an error if we …
Aug 9, 2020
5921406
<>/!=
Aug 9, 2020
887593d
Update to versions of complex and matrix libraries
Sep 1, 2020
254dcdc
Update to versions of complex and matrix libraries
Oct 1, 2020
516b63c
Separate compoer.json for PHP8 to enforce phpunit ^9.3
Oct 8, 2020
948a6f0
We don't want the composer lock file for PHP8
Oct 8, 2020
f6816ae
Work with existing composer file; but force a fresh install to requir…
Oct 8, 2020
b8ebd3f
Allow failures on nightly
Oct 8, 2020
9a7d8c9
Allow failures on nightly fails if we remove it from the grid
Oct 8, 2020
2973818
Use ZipArchive methods as zip_* functions are deprecated in PHP8
Oct 9, 2020
997ed88
Remove tests that include tcPDF and DomPDF libraries when running aga…
Oct 9, 2020
15e712a
Let's try to figure out why we're having an issue with a temp csv file
Oct 9, 2020
14c0018
Need to add `application/csv` to the list of valid CSV mime types
Oct 9, 2020
25ce484
Locale-specific float to string is changed in PHP as per https://wiki…
Oct 9, 2020
892244e
Codestyle clean-ups
Oct 9, 2020
82143be
Update composer suggestions
Oct 10, 2020
7791931
Update composer suggestions
Oct 11, 2020
eb1c64e
Test PHP 8 on GitHub Actions
PowerKiKi Oct 11, 2020
fb949f7
Improving Coverage for Excel2003 XML Reader (#1557)
oleibman Oct 11, 2020
e233a9b
Update CHANGELOG
PowerKiKi Oct 11, 2020
741d775
1.15.0
PowerKiKi Oct 11, 2020
c4ad454
Remove coverage from Travis
PowerKiKi Oct 11, 2020
1e83bde
Prepare for next version
PowerKiKi Oct 11, 2020
0b0a235
Ensure that the list of shared formulae is maintained while chunk-rea…
Oct 12, 2020
c531984
Prevent notice during accessing "cached magnification factor" offset
Sep 21, 2020
afea231
Refresh lock files
PowerKiKi Oct 19, 2020
fea1a77
Add exportArray Method for Styles (#1580)
oleibman Oct 26, 2020
3468199
Updating a misspelling of a function name. (#1695)
CoryHrycko Nov 1, 2020
62fd60b
Make DefinedNames Samples Consistent With Other Samples (#1707)
oleibman Nov 11, 2020
3a3d264
Resolve XSS Vulnerability in the HTML Writer (#1719)
Nov 19, 2020
51a9e31
Drop Travis
PowerKiKi Nov 26, 2020
6789bf8
Automatic GitHub releases from git tags
PowerKiKi Nov 26, 2020
bcf8fb3
Improve Coverage in src/PhpSpreadsheet
oleibman Nov 27, 2020
2d1375e
Changes for Scrutinizer
oleibman Nov 27, 2020
c261e62
Merged upstream/master
Dec 14, 2020
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
16 changes: 14 additions & 2 deletions src/PhpSpreadsheet/Reader/Xls.php
Original file line number Diff line number Diff line change
Expand Up @@ -2973,6 +2973,9 @@ private function readSst(): void
// offset within (spliced) record data
$pos = 0;

// Limit global SST position, further control for bad SST Length in BIFF8 data
$limitposSST = 0;

// get spliced record data
$splicedRecordData = $this->getSplicedRecordData();

Expand All @@ -2986,8 +2989,17 @@ private function readSst(): void
$nm = self::getInt4d($recordData, 4);
$pos += 4;

// look up limit position
foreach ($spliceOffsets as $spliceOffset) {
// it can happen that the string is empty, therefore we need
// <= and not just <
if ($pos <= $spliceOffset) {
$limitposSST = $spliceOffset;
}
}

// loop through the Unicode strings (16-bit length)
for ($i = 0; $i < $nm; ++$i) {
for ($i = 0; $i < $nm && $pos < $limitposSST; ++$i) {
// number of characters in the Unicode string
$numChars = self::getUInt2d($recordData, $pos);
$pos += 2;
Expand Down Expand Up @@ -3020,7 +3032,7 @@ private function readSst(): void
// expected byte length of character array if not split
$len = ($isCompressed) ? $numChars : $numChars * 2;

// look up limit position
// look up limit position - Check it again to be sure that no error occurs when parsing SST structure
foreach ($spliceOffsets as $spliceOffset) {
// it can happen that the string is empty, therefore we need
// <= and not just <
Expand Down
35 changes: 35 additions & 0 deletions tests/PhpSpreadsheetTests/Reader/XlsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,39 @@ public function testLoadXlsBug1505(): void
self::assertEquals($sheet->getCell('A1')->getFormattedValue(), $newsheet->getCell('A1')->getFormattedValue());
self::assertEquals($sheet->getCell("$col$row")->getFormattedValue(), $newsheet->getCell("$col$row")->getFormattedValue());
}

/**
* Test load Xls file with invalid length in SST map.
*/
public function testLoadXlsBug1592(): void
{
$filename = 'tests/data/Reader/XLS/bug1592.xls';
$reader = new Xls();
// When no fix applied, spreadsheet is not loaded
$spreadsheet = $reader->load($filename);
$sheet = $spreadsheet->getActiveSheet();
$col = $sheet->getHighestColumn();
$row = $sheet->getHighestRow();

$newspreadsheet = $this->writeAndReload($spreadsheet, 'Xlsx');
$newsheet = $newspreadsheet->getActiveSheet();
$newcol = $newsheet->getHighestColumn();
$newrow = $newsheet->getHighestRow();

self::assertEquals($spreadsheet->getSheetCount(), $newspreadsheet->getSheetCount());
self::assertEquals($sheet->getTitle(), $newsheet->getTitle());
self::assertEquals($sheet->getColumnDimensions(), $newsheet->getColumnDimensions());
self::assertEquals($col, $newcol);
self::assertEquals($row, $newrow);

$rowIterator = $sheet->getRowIterator();

foreach ($rowIterator as $row) {
foreach ($row->getCellIterator() as $cell) {
$valOld = $cell->getFormattedValue();
$valNew = $newsheet->getCell($cell->getCoordinate())->getFormattedValue();
self::assertEquals($valOld, $valNew);
}
}
}
}
Binary file added tests/data/Reader/XLS/bug1592.xls
Binary file not shown.