Merge pull request #21844 from bladewing/bladewing-harden-against-mimetype-mismatch

Avoid substr() error when strpos returns false
This commit is contained in:
Morris Jobke 2020-07-15 19:33:09 +02:00 committed by GitHub
commit cc258ad51a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

View File

@ -373,6 +373,8 @@ class Detection implements IMimeTypeDetector {
} }
// Try only the first part of the filetype // Try only the first part of the filetype
if (strpos($icon, '-')) {
$mimePart = substr($icon, 0, strpos($icon, '-')); $mimePart = substr($icon, 0, strpos($icon, '-'));
try { try {
$this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $mimePart . '.svg'); $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $mimePart . '.svg');
@ -380,6 +382,7 @@ class Detection implements IMimeTypeDetector {
} catch (\RuntimeException $e) { } catch (\RuntimeException $e) {
// Image for the first part of the mimetype not found // 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');
return $this->mimetypeIcons[$mimetype]; return $this->mimetypeIcons[$mimetype];