Skip to content

Commit 90abbff

Browse files
author
Frederic Delaunay
committed
FIX: simplexml_load_string() can return FALSE PHPOffice#2
1 parent 25267a9 commit 90abbff

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/PhpSpreadsheet/Reader/Xlsx.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,11 +1637,11 @@ public function load($pFilename)
16371637
}
16381638
}
16391639
}
1640-
if (FALSE !== $xmlDrawingElem = simplexml_load_string(
1640+
if (FALSE !== ($xmlDrawingElem = simplexml_load_string(
16411641
$this->securityScan($this->getFromZipArchive($zip, $fileDrawing)),
16421642
'SimpleXMLElement',
16431643
Settings::getLibXmlLoaderOptions()
1644-
))
1644+
)))
16451645
{
16461646
$xmlDrawing = $xmlDrawingElem->children('http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing');
16471647

@@ -1779,16 +1779,18 @@ public function load($pFilename)
17791779
}
17801780

17811781
// unparsed drawing AlternateContent
1782-
$xmlAltDrawing = simplexml_load_string(
1782+
if (FALSE !== ($xmlAltDrawingElem = simplexml_load_string(
17831783
$this->securityScan($this->getFromZipArchive($zip, $fileDrawing)),
17841784
'SimpleXMLElement',
17851785
Settings::getLibXmlLoaderOptions()
1786-
)->children('http://schemas.openxmlformats.org/markup-compatibility/2006');
1787-
1788-
if ($xmlAltDrawing->AlternateContent) {
1789-
foreach ($xmlAltDrawing->AlternateContent as $alternateContent) {
1790-
$unparsedLoadedData['sheets'][$docSheet->getCodeName()]['drawingAlternateContents'][] = $alternateContent->asXML();
1791-
}
1786+
)))
1787+
{
1788+
$xmlAltDrawing = $xmlAltDrawingElem->children('http://schemas.openxmlformats.org/markup-compatibility/2006');
1789+
if ($xmlAltDrawing->AlternateContent) {
1790+
foreach ($xmlAltDrawing->AlternateContent as $alternateContent) {
1791+
$unparsedLoadedData['sheets'][$docSheet->getCodeName()]['drawingAlternateContents'][] = $alternateContent->asXML();
1792+
}
1793+
}
17921794
}
17931795
}
17941796
}

0 commit comments

Comments
 (0)