Skip to content

Commit 941959d

Browse files
fixup! fix: generate favourite icon without imagick svg support
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
1 parent e4e4464 commit 941959d

File tree

6 files changed

+13
-10
lines changed

6 files changed

+13
-10
lines changed

apps/theming/lib/Controller/IconController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function getThemedIcon(string $app, string $image): Response {
8181
* Return a 32x32 favicon as png
8282
*
8383
* @param string $app ID of the app
84-
* @return DataDisplayResponse<Http::STATUS_OK, array{Content-Type: 'image/png'}>|FileDisplayResponse<Http::STATUS_OK, array{Content-Type: string}>|NotFoundResponse<Http::STATUS_NOT_FOUND, array{}>
84+
* @return DataDisplayResponse<Http::STATUS_OK, array{Content-Type: 'image/png'}>|FileDisplayResponse<Http::STATUS_OK, array{Content-Type: 'image/x-icon'}>|NotFoundResponse<Http::STATUS_NOT_FOUND, array{}>
8585
* @throws \Exception
8686
*
8787
* 200: Favicon returned
@@ -100,11 +100,11 @@ public function getFavicon(string $app = 'core'): Response {
100100
// retrieve instance favorite icon
101101
try {
102102
$iconFile = $this->imageManager->getImage('favicon', false);
103-
$response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => $iconFile->getMimeType()]);
103+
$response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/x-icon']);
104104
} catch (NotFoundException $e) {
105105
}
106106
// retrieve or generate app specific favorite icon
107-
if ($this->imageManager->canConvert('PNG')) {
107+
if (($this->imageManager->canConvert('PNG') || $this->imageManager->canConvert('SVG')) && $this->imageManager->canConvert('ICO')) {
108108
$color = $this->themingDefaults->getColorPrimary();
109109
try {
110110
$iconFile = $this->imageManager->getCachedImage('favIcon-' . $app . $color);
@@ -115,7 +115,7 @@ public function getFavicon(string $app = 'core'): Response {
115115
}
116116
$iconFile = $this->imageManager->setCachedImage('favIcon-' . $app . $color, $icon);
117117
}
118-
$response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/png']);
118+
$response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/x-icon']);
119119
}
120120
// fallback to core favorite icon
121121
if ($response === null) {

apps/theming/lib/IconBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function getFavicon($app) {
4242
$icon->setImageFormat('PNG32');
4343

4444
$favicon = new Imagick();
45-
$favicon->setFormat('PNG32');
45+
$favicon->setFormat('ICO');
4646

4747
$clone = clone $icon;
4848
$clone->scaleImage(16, 0);

apps/theming/openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@
443443
"format": "binary"
444444
}
445445
},
446-
"*/*": {
446+
"image/x-icon": {
447447
"schema": {
448448
"type": "string",
449449
"format": "binary"

apps/theming/tests/Controller/IconControllerTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,11 @@ public function testGetFaviconFail(): void {
127127
->willThrowException(new NotFoundException());
128128
$this->imageManager->expects($this->any())
129129
->method('canConvert')
130-
->with('PNG')
131-
->willReturn(false);
130+
->willReturnMap([
131+
['SVG', false],
132+
['PNG', false],
133+
['ICO', false],
134+
]);
132135
$fallbackLogo = \OC::$SERVERROOT . '/core/img/favicon.png';
133136
$this->fileAccessHelper->expects($this->once())
134137
->method('file_get_contents')

apps/theming/tests/IconBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ private function generateTestFavIcon(string $file, string $format, string $color
336336
$baseIcon->setImageFormat('PNG32');
337337

338338
$testIcon = new \Imagick();
339-
$testIcon->setFormat('PNG32');
339+
$testIcon->setFormat('ICO');
340340
foreach ([16, 32, 64, 128] as $size) {
341341
$clone = clone $baseIcon;
342342
$clone->scaleImage($size, 0);

openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33159,7 +33159,7 @@
3315933159
"format": "binary"
3316033160
}
3316133161
},
33162-
"*/*": {
33162+
"image/x-icon": {
3316333163
"schema": {
3316433164
"type": "string",
3316533165
"format": "binary"

0 commit comments

Comments
 (0)