Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions docs/changes/1.x/1.2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- Fixed PHP 8.2 deprecated about Allow access to an undefined property by [@DAdq26](https://github.com/DAdq26) in GH-2440
- Template Processor : Fixed choose dimention for Float Value by [@gdevilbat](https://github.com/gdevilbat) in GH-2449
- HTML Parser : Fix image parsing from url without extension by [@JokubasR](https://github.com/JokubasR) in GH-2459
- Word2007 Reader : Fixed reading of Office365 DocX file by [@filippotoso](https://github.com/filippotoso) & [@lfglopes](https://github.com/lfglopes) in [#2506](https://github.com/PHPOffice/PHPWord/pull/2506)

### Miscellaneous

Expand Down
2 changes: 1 addition & 1 deletion src/PhpWord/Shared/XMLReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getDomFromZip($zipFile, $xmlFile)

$zip = new ZipArchive();
$zip->open($zipFile);
$content = $zip->getFromName($xmlFile);
$content = $zip->getFromName(ltrim($xmlFile, '/'));
$zip->close();

if ($content === false) {
Expand Down
15 changes: 15 additions & 0 deletions tests/PhpWordTests/Shared/XMLReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ public function testDomFromZip(): void
self::assertFalse($reader->getDomFromZip($archiveFile, 'non_existing_xml_file.xml'));
}

/**
* Office 365 add some slash before the path of XML file.
*/
public function testDomFromZipOffice365(): void
{
$archiveFile = __DIR__ . '/../_files/xml/reader.zip';

$reader = new XMLReader();
$reader->getDomFromZip($archiveFile, '/test.xml');

self::assertTrue($reader->elementExists('/element/child'));

self::assertFalse($reader->getDomFromZip($archiveFile, 'non_existing_xml_file.xml'));
}

/**
* Test that read from non existing archive throws exception.
*/
Expand Down