From 2c11f23e973f2e64ee8ba75acd82ecb6932bc1a5 Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Sat, 6 Jan 2024 09:36:24 +0100 Subject: [PATCH] Fix preview service worker Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> Update ViewControllerTest.php Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> Update ViewController.php Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> --- apps/files/lib/Controller/ApiController.php | 1 + apps/files/lib/Controller/ViewController.php | 2 ++ apps/files/tests/Controller/ViewControllerTest.php | 1 + 3 files changed, 4 insertions(+) diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index fd0f3bdf26166..c5ac4b9afc89f 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -400,6 +400,7 @@ public function getNodeType($folderpath) { /** * @NoAdminRequired * @NoCSRFRequired + * @PublicPage */ public function serviceWorker(): StreamResponse { $response = new StreamResponse(__DIR__ . '/../../../../dist/preview-service-worker.js'); diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index d06ea49ed1748..e26d6bced6537 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -320,6 +320,8 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal ); $policy = new ContentSecurityPolicy(); $policy->addAllowedFrameDomain('\'self\''); + // Allow preview service worker + $policy->addAllowedWorkerSrcDomain('\'self\''); $response->setContentSecurityPolicy($policy); $this->provideInitialState($dir, $openfile); diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php index 64f0f10671c21..43a999bc5af93 100644 --- a/apps/files/tests/Controller/ViewControllerTest.php +++ b/apps/files/tests/Controller/ViewControllerTest.php @@ -402,6 +402,7 @@ public function testIndexWithRegularBrowser() { ); $policy = new Http\ContentSecurityPolicy(); $policy->addAllowedFrameDomain('\'self\''); + $policy->addAllowedWorkerSrcDomain('\'self\''); $expected->setContentSecurityPolicy($policy); $this->activityHelper->method('getFavoriteFilePaths')