Skip to content

Commit

Permalink
Fix preview service worker
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
solracsf committed Jan 6, 2024
1 parent ff1f3a0 commit 2c11f23
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/files/lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ public function getNodeType($folderpath) {
/**
* @NoAdminRequired
* @NoCSRFRequired
* @PublicPage
*/
public function serviceWorker(): StreamResponse {
$response = new StreamResponse(__DIR__ . '/../../../../dist/preview-service-worker.js');
Expand Down
2 changes: 2 additions & 0 deletions apps/files/lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions apps/files/tests/Controller/ViewControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ public function testIndexWithRegularBrowser() {
);
$policy = new Http\ContentSecurityPolicy();
$policy->addAllowedFrameDomain('\'self\'');
$policy->addAllowedWorkerSrcDomain('\'self\'');
$expected->setContentSecurityPolicy($policy);

$this->activityHelper->method('getFavoriteFilePaths')
Expand Down

0 comments on commit 2c11f23

Please sign in to comment.