From a41dc00f66cc57d1c316b08361596e9f0cf5abd3 Mon Sep 17 00:00:00 2001 From: binsky Date: Sat, 15 Aug 2026 18:00:23 +0200 Subject: [PATCH] fix access on uninitialized property for an unresolved ico type in IconService #858 - prevent access on uninitialized icoType/icoData - resolve icoType based on the file extension (as a fallback if not resolved before) Signed-off-by: binsky --- lib/Controller/IconController.php | 4 ++-- lib/Service/IconService.php | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/Controller/IconController.php b/lib/Controller/IconController.php index d6d0efe7c..ab4cfa175 100644 --- a/lib/Controller/IconController.php +++ b/lib/Controller/IconController.php @@ -91,9 +91,9 @@ public function getIcon($base64Url, $credentialId) { try { $icon = new IconService($url); - if ($icon->icoExists) { + if ($icon->icoExists && !empty($icon->icoData)) { $data = $icon->icoData; - $type = $icon->icoType; + $type = $icon->icoType ?? $type; } } catch (\InvalidArgumentException) { //no need to do stuff in catch diff --git a/lib/Service/IconService.php b/lib/Service/IconService.php index fcb92f6f2..fab9686e1 100644 --- a/lib/Service/IconService.php +++ b/lib/Service/IconService.php @@ -55,7 +55,7 @@ class IconService { /** * @var string favicon type (file extension, ex: ico|gif|png) */ - public string $icoType; + public ?string $icoType = null; /** * @var string favicon url determination method (default /favicon.ico or found in head>link tag) @@ -75,12 +75,12 @@ class IconService { /** * @var string md5 of $icoData */ - public string $icoMd5; + public ?string $icoMd5 = null; /** * @var string favicon binary data */ - public string $icoData; + public ?string $icoData = null; /** * @var array Additional debug info @@ -307,6 +307,10 @@ public function downloadFavicon() { return false; } + if (empty($this->icoType)) { + $this->icoType = self::getExtension($this->icoUrl); + } + // All right baby ! $this->icoData = $content; $this->icoMd5 = md5((string) $content);