Compare commits
2 Commits
9507387c8a
...
6a7b8bd8fd
Author | SHA1 | Date | |
---|---|---|---|
6a7b8bd8fd
|
|||
8d7b270f6f
|
@ -428,6 +428,12 @@ final class MD_STD {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$lang = self::lang_getfrombrowser($allowed_langs, $default_lang, "", false);
|
$lang = self::lang_getfrombrowser($allowed_langs, $default_lang, "", false);
|
||||||
|
|
||||||
|
// If the user is a bot or has no user agent at all or one of curl's,
|
||||||
|
// setting a cookie usually makes little sense.
|
||||||
|
// On the other hand, setting the cookie prevents effective caching.
|
||||||
|
if (empty($_SERVER['HTTP_USER_AGENT']) || substr($_SERVER['HTTP_USER_AGENT'], 0, 5) === 'curl/') return $lang;
|
||||||
|
|
||||||
if (!setcookie('__Host-lang', $lang, $cookie_options)) {
|
if (!setcookie('__Host-lang', $lang, $cookie_options)) {
|
||||||
throw new Exception("Failed to set language");
|
throw new Exception("Failed to set language");
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ final class MD_STD_SEC {
|
|||||||
*/
|
*/
|
||||||
public static function sendContentSecurityPolicy(array $directives, string $frame_ancestors = ""):void {
|
public static function sendContentSecurityPolicy(array $directives, string $frame_ancestors = ""):void {
|
||||||
|
|
||||||
$policy = 'Content-Security-Policy: default-src ' . $directives['default-src'] . '; connect-src ' . $directives['connect-src'] . '; script-src ' . $directives['script-src'] . '; img-src ' . $directives['img-src'] . '; media-src ' . $directives['media-src'] . '; style-src ' . $directives['style-src'] . '; font-src \'self\'; frame-src ' . $directives['frame-src'] . '; object-src ' . $directives['object-src'] . '; base-uri ' . $directives['base-uri'] . '; form-action ' . $directives['form-action'] . '; manifest-src \'self\'; worker-src \'self\';';
|
$policy = 'Content-Security-Policy: default-src ' . $directives['default-src'] . '; connect-src ' . $directives['connect-src'] . '; script-src ' . $directives['script-src'] . '; img-src ' . $directives['img-src'] . '; media-src ' . $directives['media-src'] . '; style-src ' . $directives['style-src'] . '; font-src \'self\'; frame-src ' . $directives['frame-src'] . '; object-src ' . $directives['object-src'] . '; base-uri ' . $directives['base-uri'] . '; form-action ' . $directives['form-action'] . '; manifest-src \'self\'; worker-src ' . ($directives['worker-src'] ?? '\'self\'') . ';';
|
||||||
|
|
||||||
if (!empty($frame_ancestors)) {
|
if (!empty($frame_ancestors)) {
|
||||||
$policy .= ' frame-ancestors ' . $frame_ancestors . ';';
|
$policy .= ' frame-ancestors ' . $frame_ancestors . ';';
|
||||||
|
Reference in New Issue
Block a user