From a04a01d51f6d9dc9ebc346676048e5988ea1beac Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 29 Oct 2013 12:54:30 +0100 Subject: Do not calculate $isWrapped if not needed. --- lib/private/files/type/detection.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/private/files') diff --git a/lib/private/files/type/detection.php b/lib/private/files/type/detection.php index 242a81cb5a4..d8a83382822 100644 --- a/lib/private/files/type/detection.php +++ b/lib/private/files/type/detection.php @@ -61,8 +61,6 @@ class Detection { * @return string */ public function detect($path) { - $isWrapped = (strpos($path, '://') !== false) and (substr($path, 0, 7) === 'file://'); - if (@is_dir($path)) { // directories are easy return "httpd/unix-directory"; @@ -79,6 +77,7 @@ class Detection { } 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); -- cgit v1.2.3 From 68d13210bdfa4362b984a83795498ff2c764a52b Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 29 Oct 2013 13:29:35 +0100 Subject: Reset mimetype to application/octet-stream on empty reply from file command. --- lib/private/files/type/detection.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/private/files') diff --git a/lib/private/files/type/detection.php b/lib/private/files/type/detection.php index d8a83382822..e84c63875c9 100644 --- a/lib/private/files/type/detection.php +++ b/lib/private/files/type/detection.php @@ -93,6 +93,10 @@ class Detection { //trim the newline $mimeType = trim($reply); + if (empty($mimeType)) { + $mimeType = 'application/octet-stream'; + } + } return $mimeType; } -- cgit v1.2.3 From fa6ae81149974d8becc58903d6c63594ed8b5cb4 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 29 Oct 2013 13:36:37 +0100 Subject: Return early if fileinfo is there. --- lib/private/files/type/detection.php | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/private/files') diff --git a/lib/private/files/type/detection.php b/lib/private/files/type/detection.php index e84c63875c9..d7cc9ebbf4e 100644 --- a/lib/private/files/type/detection.php +++ b/lib/private/files/type/detection.php @@ -74,6 +74,7 @@ class Detection { $info = @strtolower(finfo_file($finfo, $path)); if ($info) { $mimeType = substr($info, 0, strpos($info, ';')); + return empty($mimeType) ? 'application/octet-stream' : $mimeType; } finfo_close($finfo); } -- cgit v1.2.3 From b3e39dd3d9d94ed24d0e3e0845fd78ccb52c841d Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 29 Oct 2013 14:18:42 +0100 Subject: Map empty mimetypes to octet-stream for Oracle DBMS. --- lib/private/files/cache/cache.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/private/files') diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php index fc2d965d7f9..c1e5b34c8aa 100644 --- a/lib/private/files/cache/cache.php +++ b/lib/private/files/cache/cache.php @@ -64,6 +64,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 (empty(self::$mimetypeIds)) { $this->loadMimetypes(); } -- cgit v1.2.3