Skip to content
Snippets Groups Projects
Commit 40ae54d6 authored by Lukas Reschke's avatar Lukas Reschke
Browse files

Use actual mimetype detection instead of extension

We cannot rely on the extension as the file may also be a valid TAR or ZIP file without such content. Especially when getting resources from the ownCloud appstore.
parent 6911d8f0
No related branches found
No related tags found
No related merge requests found
......@@ -31,20 +31,20 @@
abstract class OC_Archive{
/**
* open any of the supported archive types
* Open any of the supported archive types
*
* @param string $path
* @return OC_Archive|void
*/
public static function open($path) {
$ext=substr($path, strrpos($path, '.'));
switch($ext) {
case '.zip':
$mime = \OC::$server->getMimeTypeDetector()->detect($path);
switch($mime) {
case 'application/zip':
return new OC_Archive_ZIP($path);
case '.gz':
case '.bz':
case '.bz2':
case '.tgz':
case '.tar':
case 'application/x-gzip':
return new OC_Archive_TAR($path);
case 'application/x-bzip2':
return new OC_Archive_TAR($path);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment