Skip to content

Commit

Permalink
Handle undefined array keys
Browse files Browse the repository at this point in the history
  • Loading branch information
paragonie-security committed Sep 7, 2021
1 parent bb96305 commit 3841889
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/CSPBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ public function addSource(string $directive, string $path): self
$directive = 'worker-src';
break;
}
if (!isset($this->policies[$directive])) {
$this->policies[$directive] = [];
}
if (!isset($this->policies[$directive]['allow'])) {
$this->policies[$directive]['allow'] = [];
}
if (!in_array($path, $this->policies[$directive]['allow'], true)) {
$this->policies[$directive]['allow'][] = $path;
}
Expand Down

0 comments on commit 3841889

Please sign in to comment.