diff options
author | bladewing <lukas@ifflaender-family.de> | 2020-07-15 00:10:53 +0300 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2020-11-25 14:55:20 +0300 |
commit | 0057f85ad7340e34369e7a3eb23339777b96492a (patch) | |
tree | 2d93fa7643260ef380189ef9c22840b6f02052b6 | |
parent | e84701086ab6fff70c4de8f560c6c1ea8eae3058 (diff) |
Avoid substr() error when strpos returns false
"Exception: substr() expects parameter 3 to be int, bool given" can occur on Line 378 $mimePart = substr($icon, 0, strpos($icon, '-'));
This happens, when '-' is not found and strpos returns false instead of an int.
When this occurs, e.g., Activity hangs.
Signed-off-by: lui87kw <lukas.ifflaender@uni-wuerzburg.de>
-rw-r--r-- | lib/private/Files/Type/Detection.php | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php index 4e7f89778a4..0a9de12700b 100644 --- a/lib/private/Files/Type/Detection.php +++ b/lib/private/Files/Type/Detection.php @@ -380,12 +380,15 @@ class Detection implements IMimeTypeDetector { } // Try only the first part of the filetype - $mimePart = substr($icon, 0, strpos($icon, '-')); - try { - $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $mimePart . '.svg'); - return $this->mimetypeIcons[$mimetype]; - } catch (\RuntimeException $e) { - // Image for the first part of the mimetype not found + + if(strpos($icon, '-')) { + $mimePart = substr($icon, 0, strpos($icon, '-')); + try { + $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $mimePart . '.svg'); + 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'); |