summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2015-10-31 00:55:37 +0100
committerLukas Reschke <lukas@owncloud.com>2015-10-31 00:55:37 +0100
commit40ae54d60ae56eddab28a67ebab504128ebb3ec4 (patch)
tree282eb80eb21fee8bbd7134f3874a24154397bbfd
parent6911d8f0a4e688f3c84f2dd117424f887820750a (diff)
downloadnextcloud-server-40ae54d60ae56eddab28a67ebab504128ebb3ec4.tar.gz
nextcloud-server-40ae54d60ae56eddab28a67ebab504128ebb3ec4.zip
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.
-rw-r--r--lib/private/archive.php18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/private/archive.php b/lib/private/archive.php
index 191d45296c7..54c5a71f715 100644
--- a/lib/private/archive.php
+++ b/lib/private/archive.php
@@ -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);
}
}