summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGit'Fellow <12234510+solracsf@users.noreply.github.com>2024-01-06 09:36:24 +0100
committerGit'Fellow <12234510+solracsf@users.noreply.github.com>2024-01-06 09:44:31 +0100
commit2c11f23e973f2e64ee8ba75acd82ecb6932bc1a5 (patch)
treea022893c2fa8590a8710c475495fa445b3b8a59b
parentff1f3a0a28dee5297dd1fc7a889aeae3fab67f22 (diff)
downloadnextcloud-server-2c11f23e973f2e64ee8ba75acd82ecb6932bc1a5.tar.gz
nextcloud-server-2c11f23e973f2e64ee8ba75acd82ecb6932bc1a5.zip
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>
-rw-r--r--apps/files/lib/Controller/ApiController.php1
-rw-r--r--apps/files/lib/Controller/ViewController.php2
-rw-r--r--apps/files/tests/Controller/ViewControllerTest.php1
3 files changed, 4 insertions, 0 deletions
diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php
index fd0f3bdf261..c5ac4b9afc8 100644
--- a/apps/files/lib/Controller/ApiController.php
+++ b/apps/files/lib/Controller/ApiController.php
@@ -400,6 +400,7 @@ class ApiController extends Controller {
/**
* @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 d06ea49ed17..e26d6bced65 100644
--- a/apps/files/lib/Controller/ViewController.php
+++ b/apps/files/lib/Controller/ViewController.php
@@ -320,6 +320,8 @@ class ViewController extends Controller {
);
$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 64f0f10671c..43a999bc5af 100644
--- a/apps/files/tests/Controller/ViewControllerTest.php
+++ b/apps/files/tests/Controller/ViewControllerTest.php
@@ -402,6 +402,7 @@ class ViewControllerTest extends TestCase {
);
$policy = new Http\ContentSecurityPolicy();
$policy->addAllowedFrameDomain('\'self\'');
+ $policy->addAllowedWorkerSrcDomain('\'self\'');
$expected->setContentSecurityPolicy($policy);
$this->activityHelper->method('getFavoriteFilePaths')