diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-10-23 12:54:25 +0200 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2024-10-23 15:19:24 +0000 |
commit | 2198fe16c9e17efa674e64eecaefdc5b5a15be67 (patch) | |
tree | 270c8dc33b150ed8abe418f9a894f5f35d2bbd78 /apps | |
parent | c3d52f6681877cb78dfa15ea893f6ccdeaf09d92 (diff) | |
download | nextcloud-server-2198fe16c9e17efa674e64eecaefdc5b5a15be67.tar.gz nextcloud-server-2198fe16c9e17efa674e64eecaefdc5b5a15be67.zip |
fix(app-store): Also proxy images of locally installed appsbackport/48854/stable30
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 ccd0b418040..b9eb325c9fb 100644 --- a/apps/settings/lib/Controller/AppSettingsController.php +++ b/apps/settings/lib/Controller/AppSettingsController.php @@ -229,11 +229,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; } @@ -292,7 +306,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']; } |