Add CSP frame-ancestors for #537

This commit is contained in:
the-djmaze 2023-02-21 17:23:26 +01:00
parent 2daa4f97e2
commit 66fafd3981

View file

@ -19,6 +19,7 @@ class CSP
$img = ["'self'", 'data:'],
$style = ["'self'", "'unsafe-inline'"],
$frame = [],
$frame_ancestors = [],
$report = false,
$report_to = [],
@ -29,7 +30,7 @@ class CSP
if ($default) {
foreach (\explode(';', $default) as $directive) {
$values = \explode(' ', $directive);
$name = \preg_replace('/-.+/', '', \trim(\array_shift($values)));
$name = \str_replace('-', '_', \preg_replace('/-(src)$/D', '', \trim(\array_shift($values))));
$this->$name = \array_unique(\array_merge($this->$name, $values));
}
}
@ -53,6 +54,9 @@ class CSP
if ($this->frame) {
$params[] = 'frame-src ' . \implode(' ', \array_unique($this->frame));
}
if ($this->frame_ancestors) {
$params[] = 'frame-ancestors ' . \implode(' ', \array_unique($this->frame_ancestors));
}
// Deprecated
if ($this->report) {