diff options
author | Joas Schilling <coding@schilljs.com> | 2016-09-02 13:29:30 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2016-09-05 09:48:22 +0200 |
commit | 24d90a4bb19e8f4bf6644e6ab034153d5f57f25d (patch) | |
tree | 5995eb14f9e3e947860efc57885c30912e62f521 /lib/private | |
parent | 8b484eedf029b8e1a9dcef0efb09db381888c4b0 (diff) | |
download | nextcloud-server-24d90a4bb19e8f4bf6644e6ab034153d5f57f25d.tar.gz nextcloud-server-24d90a4bb19e8f4bf6644e6ab034153d5f57f25d.zip |
Correctly remove the charset from finfo mimetype
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'); |