Skip to content

Commit

Permalink
FIX: simplexml_load_string() can return FALSE PHPOffice#2
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Delaunay committed Oct 29, 2018
1 parent 25267a9 commit 90abbff
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/PhpSpreadsheet/Reader/Xlsx.php
Original file line number Diff line number Diff line change
Expand Up @@ -1637,11 +1637,11 @@ public function load($pFilename)
}
}
}
if (FALSE !== $xmlDrawingElem = simplexml_load_string(
if (FALSE !== ($xmlDrawingElem = simplexml_load_string(
$this->securityScan($this->getFromZipArchive($zip, $fileDrawing)),
'SimpleXMLElement',
Settings::getLibXmlLoaderOptions()
))
)))
{
$xmlDrawing = $xmlDrawingElem->children('http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing');

Expand Down Expand Up @@ -1779,16 +1779,18 @@ public function load($pFilename)
}

// unparsed drawing AlternateContent
$xmlAltDrawing = simplexml_load_string(
if (FALSE !== ($xmlAltDrawingElem = simplexml_load_string(
$this->securityScan($this->getFromZipArchive($zip, $fileDrawing)),
'SimpleXMLElement',
Settings::getLibXmlLoaderOptions()
)->children('http://schemas.openxmlformats.org/markup-compatibility/2006');

if ($xmlAltDrawing->AlternateContent) {
foreach ($xmlAltDrawing->AlternateContent as $alternateContent) {
$unparsedLoadedData['sheets'][$docSheet->getCodeName()]['drawingAlternateContents'][] = $alternateContent->asXML();
}
)))
{
$xmlAltDrawing = $xmlAltDrawingElem->children('http://schemas.openxmlformats.org/markup-compatibility/2006');
if ($xmlAltDrawing->AlternateContent) {
foreach ($xmlAltDrawing->AlternateContent as $alternateContent) {
$unparsedLoadedData['sheets'][$docSheet->getCodeName()]['drawingAlternateContents'][] = $alternateContent->asXML();
}
}
}
}
}
Expand Down

0 comments on commit 90abbff

Please sign in to comment.