diff options
author | Git'Fellow <12234510+solracsf@users.noreply.github.com> | 2025-03-18 09:10:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-18 09:10:11 +0100 |
commit | 561775d2fee7c9e1b3b34b7a21bd747554f6a83e (patch) | |
tree | dd57c6c8eb44f5fa82d1237dcfc076535f9109cb | |
parent | b2ff0daab7031ae4d623027737dd8b66e2ac390f (diff) | |
parent | 55f50b485fdd4a8661e615702c4c6eebcaac370e (diff) | |
download | nextcloud-server-561775d2fee7c9e1b3b34b7a21bd747554f6a83e.tar.gz nextcloud-server-561775d2fee7c9e1b3b34b7a21bd747554f6a83e.zip |
Merge pull request #51536 from nextcloud/backport/51333/stable31
[stable31] fix(files): Make sure file pointer exists
-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 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'; } |