Fix failure when parsing xlsx with drawing having double (redefined) … (#945)

* Fix failure when parsing xlsx with drawing having double (redefined) attributes

* Fix failure when parsing xlsx with drawing having double (redefined) attributes
This commit is contained in:
kraser 2019-05-30 16:42:00 +07:00 committed by Mark Baker
parent 53ac682ba7
commit 906bdc613c
3 changed files with 21 additions and 6 deletions

View File

@ -1419,12 +1419,17 @@ class Xlsx extends BaseReader
foreach ($vmlComments as $relName => $relPath) { foreach ($vmlComments as $relName => $relPath) {
// Load VML comments file // Load VML comments file
$relPath = File::realpath(dirname("$dir/$fileWorksheet") . '/' . $relPath); $relPath = File::realpath(dirname("$dir/$fileWorksheet") . '/' . $relPath);
$vmlCommentsFile = simplexml_load_string( try {
$this->securityScanner->scan($this->getFromZipArchive($zip, $relPath)), $vmlCommentsFile = simplexml_load_string(
'SimpleXMLElement', $this->securityScanner->scan($this->getFromZipArchive($zip, $relPath)),
Settings::getLibXmlLoaderOptions() 'SimpleXMLElement',
); Settings::getLibXmlLoaderOptions()
$vmlCommentsFile->registerXPathNamespace('v', 'urn:schemas-microsoft-com:vml'); );
$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'); $shapes = $vmlCommentsFile->xpath('//v:shape');
foreach ($shapes as $shape) { foreach ($shapes as $shape) {

View File

@ -34,6 +34,16 @@ class XlsxTest extends TestCase
} }
} }
/**
* 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. * Test correct save and load xlsx files with empty drawings.
* Such files can be generated by Google Sheets. * Such files can be generated by Google Sheets.

Binary file not shown.