Skip to content

Commit

Permalink
fix(files): service worker
Browse files Browse the repository at this point in the history
This is a partial backport of 3344f0f

Co-authored-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
Signed-off-by: Sandro Jäckel <sandro.jaeckel@gmail.com>
  • Loading branch information
2 people authored and solracsf committed Jan 6, 2024
1 parent ff1f3a0 commit fb3363e
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 fb3363e

Please sign in to comment.