Merge pull request #21844 from bladewing/bladewing-harden-against-mimetype-mismatch
Avoid substr() error when strpos returns false
This commit is contained in:
commit
cc258ad51a
|
@ -373,12 +373,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');
|
||||||
|
|
Loading…
Reference in New Issue