diff options
author | Joas Schilling <coding@schilljs.com> | 2016-09-08 09:19:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-08 09:19:33 +0200 |
commit | cdfe538452b709dd181ac11fcfca72a5221c79ad (patch) | |
tree | c99d33fd3c0d735af0fbc98868b2911a05a738a4 /lib/private | |
parent | b992bf21426cd23428b56d00b67ce100bf0da4be (diff) | |
parent | 2d61ee3c13cda96c0cd4401b78bd27a586c374a9 (diff) | |
download | nextcloud-server-cdfe538452b709dd181ac11fcfca72a5221c79ad.tar.gz nextcloud-server-cdfe538452b709dd181ac11fcfca72a5221c79ad.zip |
Merge pull request #1243 from nextcloud/fix-detection-of-file-types-a-bit
Fix detection of file types a bit
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Files/Type/Detection.php | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php index 492025b7bfc..66ef0dd2aab 100644 --- a/lib/private/Files/Type/Detection.php +++ b/lib/private/Files/Type/Detection.php @@ -200,7 +200,7 @@ class Detection implements IMimeTypeDetector { $info = @strtolower(finfo_file($finfo, $path)); finfo_close($finfo); if ($info) { - $mimeType = substr($info, 0, strpos($info, ';')); + $mimeType = strpos($info, ';') !== false ? substr($info, 0, strpos($info, ';')) : $info; return empty($mimeType) ? 'application/octet-stream' : $mimeType; } @@ -238,7 +238,8 @@ class Detection implements IMimeTypeDetector { public function detectString($data) { if (function_exists('finfo_open') and function_exists('finfo_file')) { $finfo = finfo_open(FILEINFO_MIME); - return finfo_buffer($finfo, $data); + $info = finfo_buffer($finfo, $data); + return strpos($info, ';') !== false ? substr($info, 0, strpos($info, ';')) : $info; } else { $tmpFile = \OC::$server->getTempManager()->getTemporaryFile(); $fh = fopen($tmpFile, 'wb'); |