diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-01-17 18:05:43 +0400 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-01-17 18:05:43 +0400 |
commit | ae4d10668e2b4c9ca953e3681bd18a3c86093481 (patch) | |
tree | 8f87003a5358ca48ab278f6ed45dd21dd0af4de5 /lib/helper.php | |
parent | 48cd4adfb48a180e6bc869e3ffff5391ff33883b (diff) |
Fix mimetype detection
Diffstat (limited to 'lib/helper.php')
-rw-r--r-- | lib/helper.php | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/helper.php b/lib/helper.php index 71b3bd5beba..2d22f24ab38 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -390,7 +390,6 @@ class OC_Helper { * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead */ static function getMimeType($path) { - $isWrapped=(strpos($path, '://')!==false) and (substr($path, 0, 7)=='file://'); if (@is_dir($path)) { // directories are easy @@ -414,9 +413,11 @@ class OC_Helper { $info = @strtolower(finfo_file($finfo, $path)); if($info) { $mimeType=substr($info, 0, strpos($info, ';')); + return empty($mimeType) ? 'application/octet-stream' : $mimeType; } finfo_close($finfo); } + $isWrapped = (strpos($path, '://') !== false) and (substr($path, 0, 7) === 'file://'); if (!$isWrapped and $mimeType=='application/octet-stream' && function_exists("mime_content_type")) { // use mime magic extension if available $mimeType = mime_content_type($path); @@ -432,6 +433,11 @@ class OC_Helper { //trim the newline $mimeType = trim($reply); + if (empty($mimeType)) { + $mimeType = 'application/octet-stream'; + } + + } return $mimeType; } |