Improved file identification by adding a magic signature test (0x1F,0x8B as the first two characters of the file)

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@61956 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2010-10-07 10:11:37 +00:00
parent 45ac4eae14
commit f04feb78f8
1 changed files with 9 additions and 0 deletions

View File

@ -196,6 +196,15 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Read signature data (first 3 bytes)
$fh = fopen($pFilename, 'r');
$data = fread($fh, 2);
fclose($fh);
if ($data != chr(0x1F).chr(0x8B)) {
return false;
}
return true;
}