Fix code style
This commit is contained in:
parent
eda1c8a4d6
commit
38638268d8
|
@ -116,15 +116,17 @@ class Xlsx extends BaseReader
|
||||||
$zip->open($pFilename);
|
$zip->open($pFilename);
|
||||||
|
|
||||||
// The files we're looking at here are small enough that simpleXML is more efficient than XMLReader
|
// The files we're looking at here are small enough that simpleXML is more efficient than XMLReader
|
||||||
|
//~ http://schemas.openxmlformats.org/package/2006/relationships");
|
||||||
$rels = simplexml_load_string(
|
$rels = simplexml_load_string(
|
||||||
$this->securityScan($this->getFromZipArchive($zip, '_rels/.rels'))
|
$this->securityScan($this->getFromZipArchive($zip, '_rels/.rels'))
|
||||||
); //~ http://schemas.openxmlformats.org/package/2006/relationships");
|
);
|
||||||
foreach ($rels->Relationship as $rel) {
|
foreach ($rels->Relationship as $rel) {
|
||||||
switch ($rel['Type']) {
|
switch ($rel['Type']) {
|
||||||
case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument':
|
case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument':
|
||||||
|
//~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
|
||||||
$xmlWorkbook = simplexml_load_string(
|
$xmlWorkbook = simplexml_load_string(
|
||||||
$this->securityScan($this->getFromZipArchive($zip, "{$rel['Target']}"))
|
$this->securityScan($this->getFromZipArchive($zip, "{$rel['Target']}"))
|
||||||
); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
|
);
|
||||||
|
|
||||||
if ($xmlWorkbook->sheets) {
|
if ($xmlWorkbook->sheets) {
|
||||||
foreach ($xmlWorkbook->sheets->sheet as $eleSheet) {
|
foreach ($xmlWorkbook->sheets->sheet as $eleSheet) {
|
||||||
|
@ -158,8 +160,8 @@ class Xlsx extends BaseReader
|
||||||
$zip = new ZipArchive();
|
$zip = new ZipArchive();
|
||||||
$zip->open($pFilename);
|
$zip->open($pFilename);
|
||||||
|
|
||||||
$rels = simplexml_load_string(
|
|
||||||
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
||||||
|
$rels = simplexml_load_string(
|
||||||
$this->securityScan($this->getFromZipArchive($zip, '_rels/.rels')),
|
$this->securityScan($this->getFromZipArchive($zip, '_rels/.rels')),
|
||||||
'SimpleXMLElement',
|
'SimpleXMLElement',
|
||||||
Settings::getLibXmlLoaderOptions()
|
Settings::getLibXmlLoaderOptions()
|
||||||
|
@ -167,8 +169,9 @@ class Xlsx extends BaseReader
|
||||||
foreach ($rels->Relationship as $rel) {
|
foreach ($rels->Relationship as $rel) {
|
||||||
if ($rel['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument') {
|
if ($rel['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument') {
|
||||||
$dir = dirname($rel['Target']);
|
$dir = dirname($rel['Target']);
|
||||||
$relsWorkbook = simplexml_load_string(
|
|
||||||
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
||||||
|
$relsWorkbook = simplexml_load_string(
|
||||||
$this->securityScan(
|
$this->securityScan(
|
||||||
$this->getFromZipArchive($zip, "$dir/_rels/" . basename($rel['Target']) . '.rels')
|
$this->getFromZipArchive($zip, "$dir/_rels/" . basename($rel['Target']) . '.rels')
|
||||||
),
|
),
|
||||||
|
@ -184,8 +187,8 @@ class Xlsx extends BaseReader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$xmlWorkbook = simplexml_load_string(
|
|
||||||
//~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
|
//~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
|
||||||
|
$xmlWorkbook = simplexml_load_string(
|
||||||
$this->securityScan(
|
$this->securityScan(
|
||||||
$this->getFromZipArchive($zip, "{$rel['Target']}")
|
$this->getFromZipArchive($zip, "{$rel['Target']}")
|
||||||
),
|
),
|
||||||
|
@ -343,8 +346,8 @@ class Xlsx extends BaseReader
|
||||||
$zip->open($pFilename);
|
$zip->open($pFilename);
|
||||||
|
|
||||||
// Read the theme first, because we need the colour scheme when reading the styles
|
// Read the theme first, because we need the colour scheme when reading the styles
|
||||||
$wbRels = simplexml_load_string(
|
|
||||||
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
||||||
|
$wbRels = simplexml_load_string(
|
||||||
$this->securityScan($this->getFromZipArchive($zip, 'xl/_rels/workbook.xml.rels')),
|
$this->securityScan($this->getFromZipArchive($zip, 'xl/_rels/workbook.xml.rels')),
|
||||||
'SimpleXMLElement',
|
'SimpleXMLElement',
|
||||||
Settings::getLibXmlLoaderOptions()
|
Settings::getLibXmlLoaderOptions()
|
||||||
|
@ -390,8 +393,8 @@ class Xlsx extends BaseReader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$rels = simplexml_load_string(
|
|
||||||
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
||||||
|
$rels = simplexml_load_string(
|
||||||
$this->securityScan($this->getFromZipArchive($zip, '_rels/.rels')),
|
$this->securityScan($this->getFromZipArchive($zip, '_rels/.rels')),
|
||||||
'SimpleXMLElement',
|
'SimpleXMLElement',
|
||||||
Settings::getLibXmlLoaderOptions()
|
Settings::getLibXmlLoaderOptions()
|
||||||
|
@ -472,8 +475,8 @@ class Xlsx extends BaseReader
|
||||||
break;
|
break;
|
||||||
case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument':
|
case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument':
|
||||||
$dir = dirname($rel['Target']);
|
$dir = dirname($rel['Target']);
|
||||||
$relsWorkbook = simplexml_load_string(
|
|
||||||
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
||||||
|
$relsWorkbook = simplexml_load_string(
|
||||||
$this->securityScan($this->getFromZipArchive($zip, "$dir/_rels/" . basename($rel['Target']) . '.rels')),
|
$this->securityScan($this->getFromZipArchive($zip, "$dir/_rels/" . basename($rel['Target']) . '.rels')),
|
||||||
'SimpleXMLElement',
|
'SimpleXMLElement',
|
||||||
Settings::getLibXmlLoaderOptions()
|
Settings::getLibXmlLoaderOptions()
|
||||||
|
@ -482,8 +485,8 @@ class Xlsx extends BaseReader
|
||||||
|
|
||||||
$sharedStrings = [];
|
$sharedStrings = [];
|
||||||
$xpath = self::getArrayItem($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings']"));
|
$xpath = self::getArrayItem($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings']"));
|
||||||
$xmlStrings = simplexml_load_string(
|
|
||||||
//~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
|
//~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
|
||||||
|
$xmlStrings = simplexml_load_string(
|
||||||
$this->securityScan($this->getFromZipArchive($zip, "$dir/$xpath[Target]")),
|
$this->securityScan($this->getFromZipArchive($zip, "$dir/$xpath[Target]")),
|
||||||
'SimpleXMLElement',
|
'SimpleXMLElement',
|
||||||
Settings::getLibXmlLoaderOptions()
|
Settings::getLibXmlLoaderOptions()
|
||||||
|
@ -529,8 +532,8 @@ class Xlsx extends BaseReader
|
||||||
$styles = [];
|
$styles = [];
|
||||||
$cellStyles = [];
|
$cellStyles = [];
|
||||||
$xpath = self::getArrayItem($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']"));
|
$xpath = self::getArrayItem($relsWorkbook->xpath("rel:Relationship[@Type='http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles']"));
|
||||||
$xmlStyles = simplexml_load_string(
|
|
||||||
//~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
|
//~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
|
||||||
|
$xmlStyles = simplexml_load_string(
|
||||||
$this->securityScan($this->getFromZipArchive($zip, "$dir/$xpath[Target]")),
|
$this->securityScan($this->getFromZipArchive($zip, "$dir/$xpath[Target]")),
|
||||||
'SimpleXMLElement',
|
'SimpleXMLElement',
|
||||||
Settings::getLibXmlLoaderOptions()
|
Settings::getLibXmlLoaderOptions()
|
||||||
|
@ -640,8 +643,8 @@ class Xlsx extends BaseReader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$xmlWorkbook = simplexml_load_string(
|
|
||||||
//~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
|
//~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
|
||||||
|
$xmlWorkbook = simplexml_load_string(
|
||||||
$this->securityScan($this->getFromZipArchive($zip, "{$rel['Target']}")),
|
$this->securityScan($this->getFromZipArchive($zip, "{$rel['Target']}")),
|
||||||
'SimpleXMLElement',
|
'SimpleXMLElement',
|
||||||
Settings::getLibXmlLoaderOptions()
|
Settings::getLibXmlLoaderOptions()
|
||||||
|
@ -692,8 +695,8 @@ class Xlsx extends BaseReader
|
||||||
// reverse
|
// reverse
|
||||||
$docSheet->setTitle((string) $eleSheet['name'], false, false);
|
$docSheet->setTitle((string) $eleSheet['name'], false, false);
|
||||||
$fileWorksheet = $worksheets[(string) self::getArrayItem($eleSheet->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'), 'id')];
|
$fileWorksheet = $worksheets[(string) self::getArrayItem($eleSheet->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'), 'id')];
|
||||||
$xmlSheet = simplexml_load_string(
|
|
||||||
//~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
|
//~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
|
||||||
|
$xmlSheet = simplexml_load_string(
|
||||||
$this->securityScan($this->getFromZipArchive($zip, "$dir/$fileWorksheet")),
|
$this->securityScan($this->getFromZipArchive($zip, "$dir/$fileWorksheet")),
|
||||||
'SimpleXMLElement',
|
'SimpleXMLElement',
|
||||||
Settings::getLibXmlLoaderOptions()
|
Settings::getLibXmlLoaderOptions()
|
||||||
|
@ -1073,8 +1076,8 @@ class Xlsx extends BaseReader
|
||||||
}
|
}
|
||||||
// Or Date Group elements
|
// Or Date Group elements
|
||||||
foreach ($filters->dateGroupItem as $dateGroupItem) {
|
foreach ($filters->dateGroupItem as $dateGroupItem) {
|
||||||
$column->createRule()->setRule(
|
|
||||||
// Operator is undefined, but always treated as EQUAL
|
// Operator is undefined, but always treated as EQUAL
|
||||||
|
$column->createRule()->setRule(
|
||||||
null,
|
null,
|
||||||
[
|
[
|
||||||
'year' => (string) $dateGroupItem['year'],
|
'year' => (string) $dateGroupItem['year'],
|
||||||
|
@ -1111,8 +1114,8 @@ class Xlsx extends BaseReader
|
||||||
$column->setFilterType(Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER);
|
$column->setFilterType(Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER);
|
||||||
// We should only ever have one dynamic filter
|
// We should only ever have one dynamic filter
|
||||||
foreach ($filterColumn->dynamicFilter as $filterRule) {
|
foreach ($filterColumn->dynamicFilter as $filterRule) {
|
||||||
$column->createRule()->setRule(
|
|
||||||
// Operator is undefined, but always treated as EQUAL
|
// Operator is undefined, but always treated as EQUAL
|
||||||
|
$column->createRule()->setRule(
|
||||||
null,
|
null,
|
||||||
(string) $filterRule['val'],
|
(string) $filterRule['val'],
|
||||||
(string) $filterRule['type']
|
(string) $filterRule['type']
|
||||||
|
@ -1293,8 +1296,8 @@ class Xlsx extends BaseReader
|
||||||
if (!$this->readDataOnly) {
|
if (!$this->readDataOnly) {
|
||||||
// Locate hyperlink relations
|
// Locate hyperlink relations
|
||||||
if ($zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) {
|
if ($zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) {
|
||||||
$relsWorksheet = simplexml_load_string(
|
|
||||||
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
||||||
|
$relsWorksheet = simplexml_load_string(
|
||||||
$this->securityScan(
|
$this->securityScan(
|
||||||
$this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
|
$this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
|
||||||
),
|
),
|
||||||
|
@ -1342,8 +1345,8 @@ class Xlsx extends BaseReader
|
||||||
if (!$this->readDataOnly) {
|
if (!$this->readDataOnly) {
|
||||||
// Locate comment relations
|
// Locate comment relations
|
||||||
if ($zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) {
|
if ($zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) {
|
||||||
$relsWorksheet = simplexml_load_string(
|
|
||||||
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
||||||
|
$relsWorksheet = simplexml_load_string(
|
||||||
$this->securityScan(
|
$this->securityScan(
|
||||||
$this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
|
$this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
|
||||||
),
|
),
|
||||||
|
@ -1477,8 +1480,8 @@ class Xlsx extends BaseReader
|
||||||
// Header/footer images
|
// Header/footer images
|
||||||
if ($xmlSheet && $xmlSheet->legacyDrawingHF && !$this->readDataOnly) {
|
if ($xmlSheet && $xmlSheet->legacyDrawingHF && !$this->readDataOnly) {
|
||||||
if ($zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) {
|
if ($zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) {
|
||||||
$relsWorksheet = simplexml_load_string(
|
|
||||||
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
||||||
|
$relsWorksheet = simplexml_load_string(
|
||||||
$this->securityScan(
|
$this->securityScan(
|
||||||
$this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
|
$this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
|
||||||
),
|
),
|
||||||
|
@ -1495,8 +1498,8 @@ class Xlsx extends BaseReader
|
||||||
|
|
||||||
if ($vmlRelationship != '') {
|
if ($vmlRelationship != '') {
|
||||||
// Fetch linked images
|
// Fetch linked images
|
||||||
$relsVML = simplexml_load_string(
|
|
||||||
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
||||||
|
$relsVML = simplexml_load_string(
|
||||||
$this->securityScan(
|
$this->securityScan(
|
||||||
$this->getFromZipArchive($zip, dirname($vmlRelationship) . '/_rels/' . basename($vmlRelationship) . '.rels')
|
$this->getFromZipArchive($zip, dirname($vmlRelationship) . '/_rels/' . basename($vmlRelationship) . '.rels')
|
||||||
),
|
),
|
||||||
|
@ -1558,8 +1561,8 @@ class Xlsx extends BaseReader
|
||||||
|
|
||||||
// TODO: Autoshapes from twoCellAnchors!
|
// TODO: Autoshapes from twoCellAnchors!
|
||||||
if ($zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) {
|
if ($zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) {
|
||||||
$relsWorksheet = simplexml_load_string(
|
|
||||||
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
||||||
|
$relsWorksheet = simplexml_load_string(
|
||||||
$this->securityScan(
|
$this->securityScan(
|
||||||
$this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
|
$this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
|
||||||
),
|
),
|
||||||
|
@ -1575,8 +1578,8 @@ class Xlsx extends BaseReader
|
||||||
if ($xmlSheet->drawing && !$this->readDataOnly) {
|
if ($xmlSheet->drawing && !$this->readDataOnly) {
|
||||||
foreach ($xmlSheet->drawing as $drawing) {
|
foreach ($xmlSheet->drawing as $drawing) {
|
||||||
$fileDrawing = $drawings[(string) self::getArrayItem($drawing->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'), 'id')];
|
$fileDrawing = $drawings[(string) self::getArrayItem($drawing->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships'), 'id')];
|
||||||
$relsDrawing = simplexml_load_string(
|
|
||||||
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
||||||
|
$relsDrawing = simplexml_load_string(
|
||||||
$this->securityScan(
|
$this->securityScan(
|
||||||
$this->getFromZipArchive($zip, dirname($fileDrawing) . '/_rels/' . basename($fileDrawing) . '.rels')
|
$this->getFromZipArchive($zip, dirname($fileDrawing) . '/_rels/' . basename($fileDrawing) . '.rels')
|
||||||
),
|
),
|
||||||
|
@ -2333,8 +2336,8 @@ class Xlsx extends BaseReader
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$relsWorksheet = simplexml_load_string(
|
|
||||||
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
||||||
|
$relsWorksheet = simplexml_load_string(
|
||||||
$this->securityScan(
|
$this->securityScan(
|
||||||
$this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
|
$this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
|
||||||
),
|
),
|
||||||
|
@ -2365,8 +2368,8 @@ class Xlsx extends BaseReader
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$relsWorksheet = simplexml_load_string(
|
|
||||||
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
//~ http://schemas.openxmlformats.org/package/2006/relationships"
|
||||||
|
$relsWorksheet = simplexml_load_string(
|
||||||
$this->securityScan(
|
$this->securityScan(
|
||||||
$this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
|
$this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue