[Pkg-owncloud-commits] [owncloud] 335/394: simplify mimetype parsing of 'file' output

David Prévot taffit at alioth.debian.org
Fri Nov 8 23:12:44 UTC 2013


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

taffit pushed a commit to annotated tag v4.5.10
in repository owncloud.

commit 9a6676e5e7e49abae2379982febcd4634c6a0ad4
Author: Jörn Friedrich Dreyer <jfd at butonic.de>
Date:   Thu Feb 7 17:51:50 2013 +0100

    simplify mimetype parsing of 'file' output
---
 lib/helper.php |   14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/lib/helper.php b/lib/helper.php
index 3cec45a..5548b84 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -376,20 +376,14 @@ class OC_Helper {
 		}
 		if (!$isWrapped and $mimeType=='application/octet-stream' && OC_Helper::canExecute("file")) {
 			// it looks like we have a 'file' command,
-			// lets see it it does have mime support
+			// lets see if it does have mime support
 			$path=escapeshellarg($path);
-			$fp = popen("file -i -b $path 2>/dev/null", "r");
+			$fp = popen("file -b --mime-type $path 2>/dev/null", "r");
 			$reply = fgets($fp);
 			pclose($fp);
 
-			//trim the character set from the end of the response
-			$mimeType=substr($reply,0,strrpos($reply,' '));
-			$mimeType=substr($mimeType,0,strrpos($mimeType,"\n"));
-
-			//trim ;
-			if (strpos($mimeType, ';') !== false) {
-				$mimeType = strstr($mimeType, ';', true);
-			}
+			//trim the newline
+			$mimeType = trim($reply);
 
 		}
 		return $mimeType;

-- 
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