diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 55694f10..272366d7 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -1419,12 +1419,17 @@ class Xlsx extends BaseReader foreach ($vmlComments as $relName => $relPath) { // Load VML comments file $relPath = File::realpath(dirname("$dir/$fileWorksheet") . '/' . $relPath); - $vmlCommentsFile = simplexml_load_string( - $this->securityScanner->scan($this->getFromZipArchive($zip, $relPath)), - 'SimpleXMLElement', - Settings::getLibXmlLoaderOptions() - ); - $vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); + try { + $vmlCommentsFile = simplexml_load_string( + $this->securityScanner->scan($this->getFromZipArchive($zip, $relPath)), + 'SimpleXMLElement', + Settings::getLibXmlLoaderOptions() + ); + $vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); + } catch(\Throwable $ex) { + //Ignore unparsable vmlDrawings. Later they will be moved from $unparsedVmlDrawings to $unparsedLoadedData + continue; + } $shapes = $vmlCommentsFile->xpath('//v:shape'); foreach ($shapes as $shape) { diff --git a/tests/PhpSpreadsheetTests/Reader/XlsxTest.php b/tests/PhpSpreadsheetTests/Reader/XlsxTest.php index 46b30509..3653c3d1 100644 --- a/tests/PhpSpreadsheetTests/Reader/XlsxTest.php +++ b/tests/PhpSpreadsheetTests/Reader/XlsxTest.php @@ -33,6 +33,16 @@ class XlsxTest extends TestCase $this->assertEquals($ref, \array_slice($data[$i], 0, 10, true)); } } + + /** + * Test load Xlsx file with drawing having double attributes. + */ + public function testLoadXlsxWithDoubleAttrDrawing() + { + $filename = './data/Reader/XLSX/double_attr_drawing.xlsx'; + $reader = new Xlsx(); + $reader->load($filename); + } /** * Test correct save and load xlsx files with empty drawings. diff --git a/tests/data/Reader/XLSX/double_attr_drawing.xlsx b/tests/data/Reader/XLSX/double_attr_drawing.xlsx new file mode 100644 index 00000000..b8e54430 Binary files /dev/null and b/tests/data/Reader/XLSX/double_attr_drawing.xlsx differ