diff options
author | Git'Fellow <12234510+solracsf@users.noreply.github.com> | 2025-03-17 17:04:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-17 17:04:24 +0100 |
commit | dda2148f6f9e80414f8176a21b9f102c9892365d (patch) | |
tree | 31e88602beb351f9095698e3cd41ace66eff6c16 | |
parent | 5170c73390c91f214ccd92f3e8a2688c2b3599ee (diff) | |
parent | 4d52b185af702b1ee6f11a84d6218b0b422417b0 (diff) | |
download | nextcloud-server-dda2148f6f9e80414f8176a21b9f102c9892365d.tar.gz nextcloud-server-dda2148f6f9e80414f8176a21b9f102c9892365d.zip |
Merge pull request #51333 from nextcloud/filePointerCheck
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'; } |