Skip to content

Commit 35cc99f

Browse files
authored
Merge pull request #24370 from nextcloud/backport/21844/stable19
[stable19] Avoid substr() error when strpos returns false
2 parents 48ef514 + aecf4ef commit 35cc99f

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

lib/private/Files/Type/Detection.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,15 @@ public function mimeTypeIcon($mimetype): string {
379379
}
380380

381381
// Try only the first part of the filetype
382-
$mimePart = substr($icon, 0, strpos($icon, '-'));
383-
try {
384-
$this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $mimePart . '.svg');
385-
return $this->mimetypeIcons[$mimetype];
386-
} catch (\RuntimeException $e) {
387-
// Image for the first part of the mimetype not found
382+
383+
if (strpos($icon, '-')) {
384+
$mimePart = substr($icon, 0, strpos($icon, '-'));
385+
try {
386+
$this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $mimePart . '.svg');
387+
return $this->mimetypeIcons[$mimetype];
388+
} catch (\RuntimeException $e) {
389+
// Image for the first part of the mimetype not found
390+
}
388391
}
389392

390393
$this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/file.svg');

0 commit comments

Comments
 (0)