summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMorris Jobke <morris.jobke@gmail.com>2013-10-29 07:47:20 -0700
committerMorris Jobke <morris.jobke@gmail.com>2013-10-29 07:47:20 -0700
commit34c1512466e86d7de0f1ab5e26490ee114b2149d (patch)
treecfdcdba739164297d21160bd4f3f92b1f29d2a12 /lib
parent7223b5acceba1097fa1e983850f3a2652781ee4d (diff)
parentb3e39dd3d9d94ed24d0e3e0845fd78ccb52c841d (diff)
downloadnextcloud-server-34c1512466e86d7de0f1ab5e26490ee114b2149d.tar.gz
nextcloud-server-34c1512466e86d7de0f1ab5e26490ee114b2149d.zip
Merge pull request #5601 from owncloud/fix-mimetype-detection
Fix mimetype detection
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/cache/cache.php4
-rw-r--r--lib/private/files/type/detection.php8
2 files changed, 10 insertions, 2 deletions
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();
}
diff --git a/lib/private/files/type/detection.php b/lib/private/files/type/detection.php
index 242a81cb5a4..d7cc9ebbf4e 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";
@@ -76,9 +74,11 @@ 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);
}
+ $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);
@@ -94,6 +94,10 @@ class Detection {
//trim the newline
$mimeType = trim($reply);
+ if (empty($mimeType)) {
+ $mimeType = 'application/octet-stream';
+ }
+
}
return $mimeType;
}