From 21a6fc24709e00500d6574444cad234330936fad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6?= Date: Fri, 11 Aug 2023 09:03:21 +0200 Subject: [PATCH] fix(files): service worker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ --- apps/files/lib/Controller/ApiController.php | 1 + apps/files/lib/Controller/ViewController.php | 11 ++--------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index 3d490f06b75b2..bee6fb26d9e8d 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -388,6 +388,7 @@ public function getGridView() { /** * @NoAdminRequired * @NoCSRFRequired + * @PublicPage * * Get the service-worker Javascript for previews * diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 24f236a089395..e8621c1fa14e2 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -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'); @@ -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);