Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKampf committed Jul 13, 2023
1 parent 5777625 commit e4fac48
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/Listener/CSPListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace OCA\NmcMarketing\Listener;

use OC\Log;
use OCP\IConfig;
use OCP\IRequest;
use OCP\EventDispatcher\Event;
Expand All @@ -30,6 +31,7 @@ public function handle(Event $event): void {
}

$marketing_config = $this->iConfig->getSystemValue("nmc_marketing");
$userAgent = $_SERVER['HTTP_USER_AGENT'];

$policy = new EmptyContentSecurityPolicy();
$policy->useStrictDynamic(true);
Expand All @@ -38,6 +40,13 @@ public function handle(Event $event): void {
$policy->addAllowedScriptDomain($this->domainOnly($trusted_url));
}

if (strpos($userAgent, 'Edg') !== false ||
strpos($userAgent, 'MSIE') !== false) {
if ($this->request->getRequestUri() === '/' || $this->request->getRequestUri() === '/login') {
$policy->addAllowedScriptDomain("'unsafe-inline'");
}
}

foreach ($marketing_config['trusted_font_urls'] as $trusted_url) {
$policy->addAllowedFontDomain($this->domainOnly($trusted_url));
}
Expand Down

0 comments on commit e4fac48

Please sign in to comment.