mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-01 12:32:40 +08:00
Resolve #991
This commit is contained in:
parent
84008edf45
commit
a8c7146f96
2 changed files with 11 additions and 4 deletions
|
@ -16,7 +16,7 @@ class ContentSecurityPolicy extends \OCP\AppFramework\Http\ContentSecurityPolicy
|
|||
function __construct() {
|
||||
$CSP = \RainLoop\Api::getCSP();
|
||||
|
||||
$this->allowedScriptDomains = \array_unique(\array_merge($this->allowedScriptDomains, $CSP->script));
|
||||
$this->allowedScriptDomains = \array_unique(\array_merge($this->allowedScriptDomains, $CSP->get('script-src')));
|
||||
$this->allowedScriptDomains = \array_diff($this->allowedScriptDomains, ["'unsafe-inline'", "'unsafe-eval'"]);
|
||||
|
||||
// Nextcloud only sets 'strict-dynamic' when browserSupportsCspV3() ?
|
||||
|
@ -24,12 +24,12 @@ class ContentSecurityPolicy extends \OCP\AppFramework\Http\ContentSecurityPolicy
|
|||
? $this->useStrictDynamic(true) // NC24+
|
||||
: $this->addAllowedScriptDomain("'strict-dynamic'");
|
||||
|
||||
$this->allowedImageDomains = \array_unique(\array_merge($this->allowedImageDomains, $CSP->img));
|
||||
$this->allowedImageDomains = \array_unique(\array_merge($this->allowedImageDomains, $CSP->get('img-src')));
|
||||
|
||||
$this->allowedStyleDomains = \array_unique(\array_merge($this->allowedStyleDomains, $CSP->style));
|
||||
$this->allowedStyleDomains = \array_unique(\array_merge($this->allowedStyleDomains, $CSP->get('style-src')));
|
||||
$this->allowedStyleDomains = \array_diff($this->allowedStyleDomains, ["'unsafe-inline'"]);
|
||||
|
||||
$this->allowedFrameDomains = \array_unique(\array_merge($this->allowedFrameDomains, $CSP->frame));
|
||||
$this->allowedFrameDomains = \array_unique(\array_merge($this->allowedFrameDomains, $CSP->get('frame-src')));
|
||||
|
||||
$this->reportTo = \array_unique(\array_merge($this->reportTo, $CSP->report_to));
|
||||
}
|
||||
|
|
|
@ -64,6 +64,13 @@ class CSP
|
|||
$this->directives[$directive][] = $source;
|
||||
}
|
||||
|
||||
public function get(string $directive) : array
|
||||
{
|
||||
return isset($this->directives[$directive])
|
||||
? $this->directives[$directive]
|
||||
: [];
|
||||
}
|
||||
|
||||
public function setHeaders() : void
|
||||
{
|
||||
if ($this->report_only) {
|
||||
|
|
Loading…
Reference in a new issue