Merge pull request #24370 from nextcloud/backport/21844/stable19

[stable19] Avoid substr() error when strpos returns false
This commit is contained in:
Roeland Jago Douma 2020-11-25 14:42:56 +01:00 committed by GitHub
commit 35cc99fdf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

View File

@ -379,12 +379,15 @@ class Detection implements IMimeTypeDetector {
} }
// Try only the first part of the filetype // Try only the first part of the filetype
$mimePart = substr($icon, 0, strpos($icon, '-'));
try { if (strpos($icon, '-')) {
$this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $mimePart . '.svg'); $mimePart = substr($icon, 0, strpos($icon, '-'));
return $this->mimetypeIcons[$mimetype]; try {
} catch (\RuntimeException $e) { $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $mimePart . '.svg');
// Image for the first part of the mimetype not found return $this->mimetypeIcons[$mimetype];
} catch (\RuntimeException $e) {
// Image for the first part of the mimetype not found
}
} }
$this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/file.svg'); $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/file.svg');