diff options
author | icewind1991 <icewind1991@gmail.com> | 2013-02-07 14:48:26 -0800 |
---|---|---|
committer | icewind1991 <icewind1991@gmail.com> | 2013-02-07 14:48:26 -0800 |
commit | 9d7920755d742c93fe50410cd8abf37ede00fb7f (patch) | |
tree | e00b29941588c0177bca696cb6d61ea4ea46b19f | |
parent | 837c5929366f1f1a828bd03f65a62b78bd9b75c9 (diff) | |
parent | 9a6676e5e7e49abae2379982febcd4634c6a0ad4 (diff) | |
download | nextcloud-server-9d7920755d742c93fe50410cd8abf37ede00fb7f.tar.gz nextcloud-server-9d7920755d742c93fe50410cd8abf37ede00fb7f.zip |
Merge pull request #1528 from owncloud/simplify_file_mimetype_parsing_stable45
simplify mimetype parsing of 'file' output
-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; |