Merge pull request #1769 from tiagof/issue-907-absolute-path-in-Target

Handle absolute path in worksheets Target
This commit is contained in:
oleibman 2021-04-19 07:32:15 -07:00 committed by GitHub
commit 62f5135dc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 1 deletions

View File

@ -110,6 +110,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
### Fixed
- Fixed issue with absolute path in worksheets' Target. [PR #1769](https://github.com/PHPOffice/PhpSpreadsheet/pull/1769)
- Fix for Xls Reader when SST has a bad length [#1592](https://github.com/PHPOffice/PhpSpreadsheet/issues/1592)
- Resolve Xlsx loader issue whe hyperlinks don't have a destination
- Resolve issues when printer settings resources IDs clash with drawing IDs

View File

@ -198,11 +198,12 @@ class Xlsx extends BaseReader
];
$fileWorksheet = $worksheets[(string) self::getArrayItem($eleSheet->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'), 'id')];
$fileWorksheetPath = strpos($fileWorksheet, '/') === 0 ? substr($fileWorksheet, 1) : "$dir/$fileWorksheet";
$xml = new XMLReader();
$xml->xml(
$this->securityScanner->scanFile(
'zip://' . File::realpath($pFilename) . '#' . "$dir/$fileWorksheet"
'zip://' . File::realpath($pFilename) . '#' . $fileWorksheetPath
),
null,
Settings::getLibXmlLoaderOptions()

View File

@ -0,0 +1,19 @@
<?php
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PHPUnit\Framework\TestCase;
class AbsolutePathTest extends TestCase
{
public static function testPr1869(): void
{
$xlsxFile = 'tests/data/Reader/XLSX/pr1769e.xlsx';
$reader = new Xlsx();
$result = $reader->listWorksheetInfo($xlsxFile);
self::assertIsArray($result);
self::assertEquals(3, $result[0]['totalRows']);
}
}

Binary file not shown.