Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(files): Make sure file pointer exists
Signed-off-by: Git'Fellow <[email protected]>
  • Loading branch information
solracsf authored and backportbot[bot] committed Mar 17, 2025
commit 55f50b485fdd4a8661e615702c4c6eebcaac370e
16 changes: 8 additions & 8 deletions lib/private/Files/Type/Detection.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,18 @@ public function detectContent(string $path): string {
// 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';
}

Expand Down
Loading