Update addUnsafeInline() method
This commit is contained in:
parent
6209d528ca
commit
a31002325a
1 changed files with 16 additions and 6 deletions
|
@ -427,13 +427,23 @@ abstract class Page extends Model
|
|||
*/
|
||||
protected function addUnsafeInline(string $header): string
|
||||
{
|
||||
if (false === \strpos($header, 'style-src')) {
|
||||
return $header . ';style-src \'self\' \'unsafe-inline\''; // ???? брать правила с default-src ?
|
||||
} elseif (\preg_match('%style\-src[^;]+?unsafe\-inline%i', $header)) {
|
||||
return $header;
|
||||
} else {
|
||||
return \str_replace('style-src', 'style-src \'unsafe-inline\'', $header);
|
||||
if (\preg_match('%style\-src([^;]+)%', $header, $matches)) {
|
||||
if (false === \strpos($matches[1], 'unsafe-inline')) {
|
||||
return \str_replace($matches[0], "{$matches[0]} 'unsafe-inline'", $header);
|
||||
} else {
|
||||
return $header;
|
||||
}
|
||||
}
|
||||
|
||||
if (\preg_match('%default\-src([^;]+)%', $header, $matches)) {
|
||||
if (false === \strpos($matches[1], 'unsafe-inline')) {
|
||||
return "{$header};style-src{$matches[1]} 'unsafe-inline'";
|
||||
} else {
|
||||
return "{$header};style-src{$matches[1]}";
|
||||
}
|
||||
}
|
||||
|
||||
return "{$header};style-src 'self' 'unsafe-inline'";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue