Try more methods

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2019-12-10 10:56:47 +01:00 committed by Backportbot
parent b7b7380d6b
commit 877e1bb55b
1 changed files with 12 additions and 3 deletions

View File

@ -213,7 +213,10 @@ class Detection implements IMimeTypeDetector {
if ($info) { if ($info) {
$info = strtolower($info); $info = strtolower($info);
$mimeType = strpos($info, ';') !== false ? substr($info, 0, strpos($info, ';')) : $info; $mimeType = strpos($info, ';') !== false ? substr($info, 0, strpos($info, ';')) : $info;
return $this->getSecureMimeType($mimeType); $mimeType = $this->getSecureMimeType($mimeType);
if ($mimeType !== 'application/octet-stream') {
return $mimeType;
}
} }
} }
@ -226,7 +229,10 @@ class Detection implements IMimeTypeDetector {
// use mime magic extension if available // use mime magic extension if available
$mimeType = mime_content_type($path); $mimeType = mime_content_type($path);
if ($mimeType !== false) { if ($mimeType !== false) {
return $this->getSecureMimeType($mimeType); $mimeType = $this->getSecureMimeType($mimeType);
if ($mimeType !== 'application/octet-stream') {
return $mimeType;
}
} }
} }
@ -241,7 +247,10 @@ class Detection implements IMimeTypeDetector {
if ($mimeType !== false) { if ($mimeType !== false) {
//trim the newline //trim the newline
$mimeType = trim($mimeType); $mimeType = trim($mimeType);
return $this->getSecureMimeType($mimeType); $mimeType = $this->getSecureMimeType($mimeType);
if ($mimeType !== 'application/octet-stream') {
return $mimeType;
}
} }
} }