Skip to content

Commit 37ab92e

Browse files
committed
feat: clearDirective() supports report-uri
1 parent e60ee44 commit 37ab92e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

system/HTTP/ContentSecurityPolicy.php

+6
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,12 @@ protected function addToHeader(string $name, $values = null)
827827
*/
828828
public function clearDirective(string $directive): void
829829
{
830+
if ($directive === 'report-uris') {
831+
$this->{$this->directives[$directive]} = null;
832+
833+
return;
834+
}
835+
830836
$this->{$this->directives[$directive]} = [];
831837
}
832838
}

tests/system/HTTP/ContentSecurityPolicyTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -650,11 +650,14 @@ public function testClearDirective(): void
650650
$this->csp->addStyleSrc('css.example.com');
651651
$this->csp->clearDirective('style-src');
652652

653+
$this->csp->setReportURI('http://example.com/csp/reports');
654+
$this->csp->clearDirective('report-uri');
653655
$this->csp->finalize($this->response);
654656

655657
$header = $this->response->getHeaderLine('Content-Security-Policy');
656658

657659
$this->assertStringNotContainsString('style-src ', $header);
658660
$this->assertStringNotContainsString('css.example.com', $header);
661+
$this->assertStringNotContainsString('report-uri', $header);
659662
}
660663
}

0 commit comments

Comments
 (0)