Skip to content

Commit

Permalink
fix(files): service worker
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <[email protected]>
  • Loading branch information
skjnldsv committed Aug 11, 2023
1 parent af2664c commit 21a6fc2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 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 @@ -388,6 +388,7 @@ public function getGridView() {
/**
* @NoAdminRequired
* @NoCSRFRequired
* @PublicPage
*
* Get the service-worker Javascript for previews
*
Expand Down
11 changes: 2 additions & 9 deletions apps/files/lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,6 @@ public function showFile(string $fileid = null, int $openfile = 1): Response {
* @throws NotFoundException
*/
public function index($dir = '', $view = '', $fileid = null, $fileNotFound = false, $openfile = null) {

if ($fileid !== null && $dir === '') {
try {
return $this->redirectToFile($fileid);
} catch (NotFoundException $e) {
return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true]));
}
}

// Load the files we need
\OCP\Util::addStyle('files', 'merged');
\OCP\Util::addScript('files', 'merged-index', 'files');
Expand Down Expand Up @@ -242,6 +233,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

0 comments on commit 21a6fc2

Please sign in to comment.