mirror of
https://github.com/nextcloud/server.git
synced 2026-04-22 23:03:00 -04:00
fix(files): Make sure file pointer exists
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
This commit is contained in:
parent
c1533ab830
commit
55f50b485f
1 changed files with 8 additions and 8 deletions
|
|
@ -228,18 +228,18 @@ class Detection implements IMimeTypeDetector {
|
|||
// lets see if it does have mime support
|
||||
$path = escapeshellarg($path);
|
||||
$fp = popen("test -f $path && file -b --mime-type $path", 'r');
|
||||
$mimeType = fgets($fp);
|
||||
pclose($fp);
|
||||
|
||||
if ($mimeType !== false) {
|
||||
//trim the newline
|
||||
$mimeType = trim($mimeType);
|
||||
$mimeType = $this->getSecureMimeType($mimeType);
|
||||
if ($mimeType !== 'application/octet-stream') {
|
||||
if ($fp !== false) {
|
||||
$mimeType = fgets($fp);
|
||||
pclose($fp);
|
||||
if ($mimeType !== false) {
|
||||
//trim the newline
|
||||
$mimeType = trim($mimeType);
|
||||
$mimeType = $this->getSecureMimeType($mimeType);
|
||||
return $mimeType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 'application/octet-stream';
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue