Skip to content

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerKiKi authored and Frederic Delaunay committed Oct 29, 2018
1 parent 5e126cb commit f9c3384
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions src/PhpSpreadsheet/Reader/Xlsx.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,17 @@ public function listWorksheetNames($pFilename)
$zip->open($pFilename);

// 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(
$this->securityScan($this->getFromZipArchive($zip, '_rels/.rels'))
); //~ http://schemas.openxmlformats.org/package/2006/relationships");
);
foreach ($rels->Relationship as $rel) {
switch ($rel['Type']) {
case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument':
//~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
$xmlWorkbook = simplexml_load_string(
$this->securityScan($this->getFromZipArchive($zip, "{$rel['Target']}"))
); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
);

if ($xmlWorkbook->sheets) {
foreach ($xmlWorkbook->sheets->sheet as $eleSheet) {
Expand Down Expand Up @@ -158,17 +160,18 @@ public function listWorksheetInfo($pFilename)
$zip = new ZipArchive();
$zip->open($pFilename);

$rels = simplexml_load_string(
//~ http://schemas.openxmlformats.org/package/2006/relationships"
$rels = simplexml_load_string(
$this->securityScan($this->getFromZipArchive($zip, '_rels/.rels')),
'SimpleXMLElement',
Settings::getLibXmlLoaderOptions()
);
foreach ($rels->Relationship as $rel) {
if ($rel['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument') {
$dir = dirname($rel['Target']);
$relsWorkbook = simplexml_load_string(

//~ http://schemas.openxmlformats.org/package/2006/relationships"
$relsWorkbook = simplexml_load_string(
$this->securityScan(
$this->getFromZipArchive($zip, "$dir/_rels/" . basename($rel['Target']) . '.rels')
),
Expand All @@ -184,8 +187,8 @@ public function listWorksheetInfo($pFilename)
}
}

$xmlWorkbook = simplexml_load_string(
//~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
$xmlWorkbook = simplexml_load_string(
$this->securityScan(
$this->getFromZipArchive($zip, "{$rel['Target']}")
),
Expand Down Expand Up @@ -343,8 +346,8 @@ public function load($pFilename)
$zip->open($pFilename);

// 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"
$wbRels = simplexml_load_string(
$this->securityScan($this->getFromZipArchive($zip, 'xl/_rels/workbook.xml.rels')),
'SimpleXMLElement',
Settings::getLibXmlLoaderOptions()
Expand Down Expand Up @@ -390,8 +393,8 @@ public function load($pFilename)
}
}

$rels = simplexml_load_string(
//~ http://schemas.openxmlformats.org/package/2006/relationships"
$rels = simplexml_load_string(
$this->securityScan($this->getFromZipArchive($zip, '_rels/.rels')),
'SimpleXMLElement',
Settings::getLibXmlLoaderOptions()
Expand Down Expand Up @@ -472,8 +475,8 @@ public function load($pFilename)
break;
case 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument':
$dir = dirname($rel['Target']);
$relsWorkbook = simplexml_load_string(
//~ http://schemas.openxmlformats.org/package/2006/relationships"
$relsWorkbook = simplexml_load_string(
$this->securityScan($this->getFromZipArchive($zip, "$dir/_rels/" . basename($rel['Target']) . '.rels')),
'SimpleXMLElement',
Settings::getLibXmlLoaderOptions()
Expand All @@ -482,8 +485,8 @@ public function load($pFilename)

$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"
$xmlStrings = simplexml_load_string(
$this->securityScan($this->getFromZipArchive($zip, "$dir/$xpath[Target]")),
'SimpleXMLElement',
Settings::getLibXmlLoaderOptions()
Expand Down Expand Up @@ -529,8 +532,8 @@ public function load($pFilename)
$styles = [];
$cellStyles = [];
$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"
$xmlStyles = simplexml_load_string(
$this->securityScan($this->getFromZipArchive($zip, "$dir/$xpath[Target]")),
'SimpleXMLElement',
Settings::getLibXmlLoaderOptions()
Expand Down Expand Up @@ -640,8 +643,8 @@ public function load($pFilename)
}
}

$xmlWorkbook = simplexml_load_string(
//~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
$xmlWorkbook = simplexml_load_string(
$this->securityScan($this->getFromZipArchive($zip, "{$rel['Target']}")),
'SimpleXMLElement',
Settings::getLibXmlLoaderOptions()
Expand Down Expand Up @@ -692,8 +695,8 @@ public function load($pFilename)
// reverse
$docSheet->setTitle((string) $eleSheet['name'], false, false);
$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"
$xmlSheet = simplexml_load_string(
$this->securityScan($this->getFromZipArchive($zip, "$dir/$fileWorksheet")),
'SimpleXMLElement',
Settings::getLibXmlLoaderOptions()
Expand Down Expand Up @@ -1073,8 +1076,8 @@ public function load($pFilename)
}
// Or Date Group elements
foreach ($filters->dateGroupItem as $dateGroupItem) {
$column->createRule()->setRule(
// Operator is undefined, but always treated as EQUAL
$column->createRule()->setRule(
null,
[
'year' => (string) $dateGroupItem['year'],
Expand Down Expand Up @@ -1111,8 +1114,8 @@ public function load($pFilename)
$column->setFilterType(Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER);
// We should only ever have one dynamic filter
foreach ($filterColumn->dynamicFilter as $filterRule) {
$column->createRule()->setRule(
// Operator is undefined, but always treated as EQUAL
$column->createRule()->setRule(
null,
(string) $filterRule['val'],
(string) $filterRule['type']
Expand Down Expand Up @@ -1308,8 +1311,8 @@ public function load($pFilename)
if (!$this->readDataOnly) {
// Locate hyperlink relations
if ($zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) {
$relsWorksheet = simplexml_load_string(
//~ http://schemas.openxmlformats.org/package/2006/relationships"
$relsWorksheet = simplexml_load_string(
$this->securityScan(
$this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
),
Expand Down Expand Up @@ -1357,8 +1360,8 @@ public function load($pFilename)
if (!$this->readDataOnly) {
// Locate comment relations
if ($zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) {
$relsWorksheet = simplexml_load_string(
//~ http://schemas.openxmlformats.org/package/2006/relationships"
$relsWorksheet = simplexml_load_string(
$this->securityScan(
$this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
),
Expand Down Expand Up @@ -1492,8 +1495,8 @@ public function load($pFilename)
// Header/footer images
if ($xmlSheet && $xmlSheet->legacyDrawingHF && !$this->readDataOnly) {
if ($zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) {
$relsWorksheet = simplexml_load_string(
//~ http://schemas.openxmlformats.org/package/2006/relationships"
$relsWorksheet = simplexml_load_string(
$this->securityScan(
$this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
),
Expand All @@ -1510,8 +1513,8 @@ public function load($pFilename)

if ($vmlRelationship != '') {
// Fetch linked images
$relsVML = simplexml_load_string(
//~ http://schemas.openxmlformats.org/package/2006/relationships"
$relsVML = simplexml_load_string(
$this->securityScan(
$this->getFromZipArchive($zip, dirname($vmlRelationship) . '/_rels/' . basename($vmlRelationship) . '.rels')
),
Expand Down Expand Up @@ -1573,8 +1576,8 @@ public function load($pFilename)

// TODO: Autoshapes from twoCellAnchors!
if ($zip->locateName(dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')) {
$relsWorksheet = simplexml_load_string(
//~ http://schemas.openxmlformats.org/package/2006/relationships"
$relsWorksheet = simplexml_load_string(
$this->securityScan(
$this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
),
Expand All @@ -1590,8 +1593,8 @@ public function load($pFilename)
if ($xmlSheet->drawing && !$this->readDataOnly) {
foreach ($xmlSheet->drawing as $drawing) {
$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"
$relsDrawing = simplexml_load_string(
$this->securityScan(
$this->getFromZipArchive($zip, dirname($fileDrawing) . '/_rels/' . basename($fileDrawing) . '.rels')
),
Expand Down Expand Up @@ -2348,8 +2351,8 @@ private function readFormControlProperties(Spreadsheet $excel, ZipArchive $zip,
return;
}

$relsWorksheet = simplexml_load_string(
//~ http://schemas.openxmlformats.org/package/2006/relationships"
$relsWorksheet = simplexml_load_string(
$this->securityScan(
$this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
),
Expand Down Expand Up @@ -2380,8 +2383,8 @@ private function readPrinterSettings(Spreadsheet $excel, ZipArchive $zip, $dir,
return;
}

$relsWorksheet = simplexml_load_string(
//~ http://schemas.openxmlformats.org/package/2006/relationships"
$relsWorksheet = simplexml_load_string(
$this->securityScan(
$this->getFromZipArchive($zip, dirname("$dir/$fileWorksheet") . '/_rels/' . basename($fileWorksheet) . '.rels')
),
Expand Down

0 comments on commit f9c3384

Please sign in to comment.