diff options
author | Git'Fellow <12234510+solracsf@users.noreply.github.com> | 2025-03-07 19:16:30 +0100 |
---|---|---|
committer | Andy Scherzinger <info@andy-scherzinger.de> | 2025-03-19 23:25:14 +0100 |
commit | 52669438a66513f827cc6b530ae32c3be1a58e5b (patch) | |
tree | 6d09bc72498a565b4eb0b88977b7846d9f9cff51 | |
parent | fed573ad3573cf91297d9637a99a5ec2b5804429 (diff) | |
download | nextcloud-server-52669438a66513f827cc6b530ae32c3be1a58e5b.tar.gz nextcloud-server-52669438a66513f827cc6b530ae32c3be1a58e5b.zip |
fix(files): Make sure file pointer existsbackport/51333/stable29
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
-rw-r--r-- | lib/private/Files/Type/Detection.php | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php index 05901a6f0b9..23f14e3c1cb 100644 --- a/lib/private/Files/Type/Detection.php +++ b/lib/private/Files/Type/Detection.php @@ -273,18 +273,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'; } |