[Pkg-owncloud-commits] [owncloud] 09/69: Use actual mimetype detection instead of extension

David Prévot taffit at moszumanska.debian.org
Wed Nov 11 02:03:58 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch stable8
in repository owncloud.

commit 5814e636fb4d2e1b8fccbe31f48c9ee1bf51f446
Author: Lukas Reschke <lukas at owncloud.com>
Date:   Sat Oct 31 00:55:37 2015 +0100

    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.
---
 lib/private/archive.php | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/private/archive.php b/lib/private/archive.php
index 191d452..54c5a71 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);
 		}
 	}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list