Skip to content

Commit

Permalink
When building from aggregated violations, the list of allowed domains…
Browse files Browse the repository at this point in the history
… will contain many duplicate entries. This is the most simple fix to remove the duplication

Preferably, a public function hasSource(string $directive, string $path): bool would be available to prevent adding in the first place, but array_unique will do the trick for now
  • Loading branch information
rmpel committed Mar 20, 2024
1 parent fa924eb commit 06624d7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/CSPBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ protected function compileSubgroup(string $directive, $policies = []): string
if (!empty($policies['allow'])) {
/** @var array<array-key, string> $allowedPolicies */
$allowedPolicies = $policies['allow'];
foreach ($allowedPolicies as $url) {
foreach (array_unique($allowedPolicies) as $url) {
/** @var string|bool $url */
$url = filter_var($url, FILTER_SANITIZE_URL);
if (is_string($url)) {
Expand Down

0 comments on commit 06624d7

Please sign in to comment.