diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-01-27 16:55:53 +0100 |
---|---|---|
committer | Carl Schwan <carl@carlschwan.eu> | 2022-01-27 17:03:09 +0100 |
commit | 760db78dbac8ac81f58dd0f2797b7d76fb0af239 (patch) | |
tree | 46039014032ef740a05775c7c679aeaa5cb7875e /apps | |
parent | f778cbe7b9f0c41e25a0e2fe1031e969ba04c2c1 (diff) | |
download | nextcloud-server-760db78dbac8ac81f58dd0f2797b7d76fb0af239.tar.gz nextcloud-server-760db78dbac8ac81f58dd0f2797b7d76fb0af239.zip |
Add better error handling
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/theming/lib/Controller/IconController.php | 10 | ||||
-rw-r--r-- | apps/theming/lib/ThemingDefaults.php | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/apps/theming/lib/Controller/IconController.php b/apps/theming/lib/Controller/IconController.php index da6668c4906..45d3ee14e47 100644 --- a/apps/theming/lib/Controller/IconController.php +++ b/apps/theming/lib/Controller/IconController.php @@ -107,7 +107,7 @@ class IconController extends Controller { * @NoCSRFRequired * * @param $app string app name - * @return FileDisplayResponse|DataDisplayResponse + * @return FileDisplayResponse|DataDisplayResponse|NotFoundResponse * @throws \Exception */ public function getFavicon(string $app = 'core'): Response { @@ -123,6 +123,9 @@ class IconController extends Controller { $iconFile = $this->imageManager->getCachedImage('favIcon-' . $app); } catch (NotFoundException $exception) { $icon = $this->iconBuilder->getFavicon($app); + if ($icon === false || $icon === '') { + return new NotFoundResponse(); + } $iconFile = $this->imageManager->setCachedImage('favIcon-' . $app, $icon); } $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/x-icon']); @@ -142,7 +145,7 @@ class IconController extends Controller { * @NoCSRFRequired * * @param $app string app name - * @return DataDisplayResponse|FileDisplayResponse + * @return DataDisplayResponse|FileDisplayResponse|NotFoundResponse * @throws \Exception */ public function getTouchIcon(string $app = 'core'): Response { @@ -157,6 +160,9 @@ class IconController extends Controller { $iconFile = $this->imageManager->getCachedImage('touchIcon-' . $app); } catch (NotFoundException $exception) { $icon = $this->iconBuilder->getTouchIcon($app); + if ($icon === false || $icon === '') { + return new NotFoundResponse(); + } $iconFile = $this->imageManager->setCachedImage('touchIcon-' . $app, $icon); } $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/png']); diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 74b75372083..3d7aaee2064 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -158,7 +158,7 @@ class ThemingDefaults extends \OC_Defaults { } /** - * We pass a string and sanitizeHTML will return a string to in that case + * We pass a string and sanitizeHTML will return a string too in that case * @psalm-suppress InvalidReturnStatement * @psalm-suppress InvalidReturnType */ |