Skip to content

Commit

Permalink
PDFViewer / CSP - frame-src object-src blob: (#8498)
Browse files Browse the repository at this point in the history
  • Loading branch information
vkael authored Feb 27, 2023
1 parent f150fb0 commit 752a6ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/bugfix-oc10-pdf-display
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: PDF display issue - Update CSP object-src policy

PDF display is associated with object-src / frame-src policy with blob values.

We allow those for only : 'self' blob:;

https://github.com/owncloud/web/pull/8498
20 changes: 12 additions & 8 deletions packages/web-integration-oc10/lib/Controller/FilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,20 @@ public function getFile(string $path): Response {
$response->setContentSecurityPolicy($csp);
}
if (\strpos($path, "index.html") === 0) {
$csp = new ContentSecurityPolicy();
$csp->allowInlineScript(true);
$csp = $this->applyCSPOpenIDConnect($csp);
$csp = new ContentSecurityPolicy();
$csp->allowInlineScript(true);
$csp = $this->applyCSPOpenIDConnect($csp);

// Required to support PDF Viewer
$csp->addAllowedFrameDomain('\'self\'');
$csp->addAllowedObjectDomain('\'self\' blob:');

// for now we set CSP rules manually, until we have sufficient requirements for a generic solution.
$csp = $this->applyCSPOnlyOffice($csp);
$csp = $this->applyCSPRichDocuments($csp);
// for now we set CSP rules manually, until we have sufficient requirements for a generic solution.
$csp = $this->applyCSPOnlyOffice($csp);
$csp = $this->applyCSPRichDocuments($csp);

$response->setContentSecurityPolicy($csp);
}
$response->setContentSecurityPolicy($csp);
}

return $response;
}
Expand Down

0 comments on commit 752a6ba

Please sign in to comment.