From 7dafd5831fad2c2be79c3df81fb973c00ec76287 Mon Sep 17 00:00:00 2001 From: bladewing Date: Tue, 14 Jul 2020 23:10:53 +0200 Subject: [PATCH 1/2] 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 --- lib/private/Files/Type/Detection.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php index e882503766..34caf072d9 100644 --- a/lib/private/Files/Type/Detection.php +++ b/lib/private/Files/Type/Detection.php @@ -373,12 +373,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'); From 3fe3d1fca32a033692201705bb59992f140e8799 Mon Sep 17 00:00:00 2001 From: lui87kw Date: Tue, 14 Jul 2020 23:36:23 +0200 Subject: [PATCH 2/2] Extra white space to follow other ifs Signed-off-by: lui87kw --- lib/private/Files/Type/Detection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php index 34caf072d9..bfca6dabd2 100644 --- a/lib/private/Files/Type/Detection.php +++ b/lib/private/Files/Type/Detection.php @@ -374,7 +374,7 @@ class Detection implements IMimeTypeDetector { // Try only the first part of the filetype - if(strpos($icon, '-')) { + if (strpos($icon, '-')) { $mimePart = substr($icon, 0, strpos($icon, '-')); try { $this->mimetypeIcons[$mimetype] = $this->urlGenerator->imagePath('core', 'filetypes/' . $mimePart . '.svg');