diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-07-15 19:33:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-15 19:33:09 +0200 |
commit | cc258ad51afedb6ebabc112d627e2f9bfd0c5763 (patch) | |
tree | 9368a2373d756f96caf1afdf987450491dc63f5e /lib | |
parent | 638e9438a937c5f81b374ec3f1db2872215290ae (diff) | |
parent | 3fe3d1fca32a033692201705bb59992f140e8799 (diff) | |
download | nextcloud-server-cc258ad51afedb6ebabc112d627e2f9bfd0c5763.tar.gz nextcloud-server-cc258ad51afedb6ebabc112d627e2f9bfd0c5763.zip |
Merge pull request #21844 from bladewing/bladewing-harden-against-mimetype-mismatch
Avoid substr() error when strpos returns false
Diffstat (limited to 'lib')
-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 e8825037666..bfca6dabd2f 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'); |