mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 16:26:59 -04:00
Merge pull request #5601 from owncloud/fix-mimetype-detection
Fix mimetype detection
This commit is contained in:
commit
34c1512466
2 changed files with 10 additions and 2 deletions
4
lib/private/files/cache/cache.php
vendored
4
lib/private/files/cache/cache.php
vendored
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue