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
SuperSandro2000 and skjnldsv committed Oct 21, 2023
1 parent 423f4e6 commit ce85de5
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 ce85de5

Please sign in to comment.