Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2020-11-25 16:42:37 +0300
committerGitHub <noreply@github.com>2020-11-25 16:42:37 +0300
commit71b176d5e0c507c8af00a28a12125439b3e3c7fc (patch)
treedfaacf827fcea69b47183eadd39b412fae4c5e8e
parente84701086ab6fff70c4de8f560c6c1ea8eae3058 (diff)
parent3952be00eced8cdc069c9ca54cef3d7b428d8e6c (diff)
Merge pull request #24371 from nextcloud/backport/21844/stable18
[stable18] Avoid substr() error when strpos returns false
-rw-r--r--lib/private/Files/Type/Detection.php15
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..9e85115f0a9 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');