]> source.dussan.org Git - nextcloud-server.git/commitdiff
simplyfy mimetype parsing of 'file' output
authorJörn Friedrich Dreyer <jfd@butonic.de>
Thu, 7 Feb 2013 16:42:03 +0000 (17:42 +0100)
committerJörn Friedrich Dreyer <jfd@butonic.de>
Thu, 7 Feb 2013 16:46:16 +0000 (17:46 +0100)
lib/helper.php

index 0e549d006a1fd7540ce0372dc5d30c86f53045a6..a0fbdd10394f3e904d71fe0d24b62d76cb22aa05 100644 (file)
@@ -394,13 +394,12 @@ class OC_Helper {
                        // it looks like we have a 'file' command,
                        // 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);
 
-                       // we have smth like 'text/x-c++; charset=us-ascii\n'
-                       // and need to eliminate everything starting with semicolon including trailing LF
-                       $mimeType = preg_replace('/;.*/ms', '', trim($reply));
+                       //trim the newline
+                       $mimeType = trim($reply);
 
                }
                return $mimeType;