mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-30 01:06:03 +03:00
Additional validation check in the canLoad() method of Excel2007 Reader to return false for OpenXML documents that aren't workbooks (eg. pptx, docx)
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@64373 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
f2bed9ca37
commit
fcf2643609
@ -168,18 +168,26 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
|
|||||||
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$xl = false;
|
||||||
// Load file
|
// Load file
|
||||||
$zip = new ZipArchive;
|
$zip = new ZipArchive;
|
||||||
if ($zip->open($pFilename) === true) {
|
if ($zip->open($pFilename) === true) {
|
||||||
// check if it is an OOXML archive
|
// check if it is an OOXML archive
|
||||||
$rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels"));
|
$rels = simplexml_load_string($this->_getFromZipArchive($zip, "_rels/.rels"));
|
||||||
|
foreach ($rels->Relationship as $rel) {
|
||||||
|
switch ($rel["Type"]) {
|
||||||
|
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument":
|
||||||
|
if (basename($rel["Target"]) == 'workbook.xml') {
|
||||||
|
$xl = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
$zip->close();
|
$zip->close();
|
||||||
|
|
||||||
return ($rels !== false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return $xl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _castToBool($c) {
|
private function _castToBool($c) {
|
||||||
|
Loading…
Reference in New Issue
Block a user