Skip to content

Commit 3a90ae4

Browse files
committed
fix(theming): fix getImage MIME type using appConfig and original file check
Signed-off-by: Anna Larch <anna@nextcloud.com> AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 63d7478 commit 3a90ae4

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

apps/theming/lib/Controller/ThemingController.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,14 @@ public function getImage(string $key, bool $useSvg = true) {
376376
$csp->allowInlineStyle();
377377
$response->setContentSecurityPolicy($csp);
378378
$response->cacheFor(3600);
379-
$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', ''));
379+
// The original stored file has no extension (e.g. "logo"), so getMimeType() returns
380+
// application/octet-stream for it. Use the config-stored MIME type for the original
381+
// file, and getMimeType() only for converted files which have a proper extension.
382+
$mimeType = $file->getName() === $key
383+
? $this->appConfig->getAppValueString($key . 'Mime', '')
384+
: $file->getMimeType();
385+
$response->addHeader('Content-Type', $mimeType);
380386
$response->addHeader('Content-Disposition', 'attachment; filename="' . $key . '"');
381-
if (!$useSvg) {
382-
$response->addHeader('Content-Type', 'image/png');
383-
} else {
384-
$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', ''));
385-
}
386387
return $response;
387388
}
388389

0 commit comments

Comments
 (0)