aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGit'Fellow <12234510+solracsf@users.noreply.github.com>2025-03-07 19:16:30 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2025-03-17 16:04:47 +0000
commit552c5e8cefbb4feca636750556463b38f6ea8b5e (patch)
tree3abc5e23f9f125bce870f50c7d06384a7c2b5fbe /lib
parent401c051ba7a2c502ea99c731ab071e90f9beb0dc (diff)
downloadnextcloud-server-backport/51333/stable30.tar.gz
nextcloud-server-backport/51333/stable30.zip
fix(files): Make sure file pointer existsbackport/51333/stable30
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Type/Detection.php16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php
index 3676a9b736c..48907b3473f 100644
--- a/lib/private/Files/Type/Detection.php
+++ b/lib/private/Files/Type/Detection.php
@@ -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';
}