diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-10-23 12:54:25 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-10-23 13:36:27 +0200 |
commit | 3b6915e96dd975ea30655733606f300253e1492e (patch) | |
tree | 0c84446c860764ee909cbd74620d4a6c2b1f0296 /apps | |
parent | 74cd6e295a8e2e7c64e4fe38ba775986c57509a4 (diff) | |
download | nextcloud-server-3b6915e96dd975ea30655733606f300253e1492e.tar.gz nextcloud-server-3b6915e96dd975ea30655733606f300253e1492e.zip |
fix(app-store): Also proxy images of locally installed appsfix/proxy-app-screenshot
Before this only app store apps got their screenshots proxied,
but this will cause locally installed apps to not be correctly shown on the app-store.
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/settings/lib/Controller/AppSettingsController.php | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/apps/settings/lib/Controller/AppSettingsController.php b/apps/settings/lib/Controller/AppSettingsController.php index 7a1e5dd7157..d2680173020 100644 --- a/apps/settings/lib/Controller/AppSettingsController.php +++ b/apps/settings/lib/Controller/AppSettingsController.php @@ -230,11 +230,25 @@ class AppSettingsController extends Controller { ], $categories); } + /** + * Convert URL to proxied URL so CSP is no problem + */ + private function createProxyPreviewUrl(string $url): string { + if ($url === '') { + return ''; + } + return 'https://usercontent.apps.nextcloud.com/' . base64_encode($url); + } + private function fetchApps() { $appClass = new \OC_App(); $apps = $appClass->listAllApps(); foreach ($apps as $app) { $app['installed'] = true; + // locally installed apps have a flatted screenshot property + if (isset($app['screenshot'][0])) { + $app['screenshot'] = $this->createProxyPreviewUrl($app['screenshot'][0]); + } $this->allApps[$app['id']] = $app; } @@ -293,7 +307,7 @@ class AppSettingsController extends Controller { $apps = array_map(function (array $appData) use ($dependencyAnalyzer, $ignoreMaxApps) { if (isset($appData['appstoreData'])) { $appstoreData = $appData['appstoreData']; - $appData['screenshot'] = isset($appstoreData['screenshots'][0]['url']) ? 'https://usercontent.apps.nextcloud.com/' . base64_encode($appstoreData['screenshots'][0]['url']) : ''; + $appData['screenshot'] = $this->createProxyPreviewUrl($appstoreData['screenshots'][0]['url'] ?? ''); $appData['category'] = $appstoreData['categories']; $appData['releases'] = $appstoreData['releases']; } |