diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-02-07 17:51:50 +0100 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-02-07 17:51:50 +0100 |
commit | 9a6676e5e7e49abae2379982febcd4634c6a0ad4 (patch) | |
tree | e00b29941588c0177bca696cb6d61ea4ea46b19f /lib | |
parent | 837c5929366f1f1a828bd03f65a62b78bd9b75c9 (diff) | |
download | nextcloud-server-9a6676e5e7e49abae2379982febcd4634c6a0ad4.tar.gz nextcloud-server-9a6676e5e7e49abae2379982febcd4634c6a0ad4.zip |
simplify mimetype parsing of 'file' output
Diffstat (limited to 'lib')
-rw-r--r-- | lib/helper.php | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/helper.php b/lib/helper.php index 3cec45a0953..5548b84edc3 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; |