diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d53073593..bb09f62885 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 3895358af3..a3dcf6c222 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -198,11 +198,12 @@ public function listWorksheetInfo($pFilename) ]; $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() diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/AbsolutePathTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/AbsolutePathTest.php new file mode 100644 index 0000000000..6a886abb4a --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/AbsolutePathTest.php @@ -0,0 +1,19 @@ +listWorksheetInfo($xlsxFile); + + self::assertIsArray($result); + self::assertEquals(3, $result[0]['totalRows']); + } +} diff --git a/tests/data/Reader/XLSX/pr1769e.xlsx b/tests/data/Reader/XLSX/pr1769e.xlsx new file mode 100644 index 0000000000..7492828f03 Binary files /dev/null and b/tests/data/Reader/XLSX/pr1769e.xlsx differ