]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix mimetype detection
authorJörn Friedrich Dreyer <jfd@butonic.de>
Fri, 17 Jan 2014 14:05:43 +0000 (15:05 +0100)
committerJörn Friedrich Dreyer <jfd@butonic.de>
Fri, 17 Jan 2014 14:05:43 +0000 (15:05 +0100)
lib/files/cache/cache.php
lib/helper.php

index 32cad6b84b28af4b5f515236607c319486337b35..a2a7a99697020e9dd84ab8d95c85f72cfa1c7e57 100644 (file)
@@ -91,6 +91,10 @@ class Cache {
         * @return int
         */
        public function getMimetypeId($mime) {
+               if (empty($mime)) {
+                       // Can not insert empty string into Oracle NOT NULL column.
+                       $mime = 'application/octet-stream';
+               }
                if (!isset($this->mimetypeIds[$mime])) {
                        $result = \OC_DB::executeAudited(
                                'SELECT `id` FROM `*PREFIX*mimetypes` WHERE `mimetype` = ?',
index 71b3bd5bebaeb42b1babb5bd0d5dd4f93a7c8372..2d22f24ab3882d4f71578196714f09be88b640db 100644 (file)
@@ -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;
        }