Skip to content

Commit

Permalink
Add Content-Security-Policy header
Browse files Browse the repository at this point in the history
This is standard and obsoletes X-Content-Security-Policy and
X-Webkit-CSP, but we still keep the old ones to provide headers for old
browsers.

Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information
nijel committed Mar 19, 2014
1 parent 7862564 commit 5199ad8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions libraries/Header.class.php
Expand Up @@ -470,6 +470,20 @@ public function sendHttpHeaders()
'X-Frame-Options: DENY'
);
}
header(
"Content-Security-Policy: default-src 'self' "
. ($use_captcha ? 'https://www.google.com ' : ' ')
. $GLOBALS['cfg']['CSPAllow'] . ';'
. "script-src 'self' 'unsafe-inline' 'unsafe-eval'"
. ($use_captcha ? 'https://www.google.com ' : ' ')
. ";"
. "img-src 'self' data: "
. $GLOBALS['cfg']['CSPAllow']
. ($https ? "" : $mapTilesUrls)
// for reCAPTCHA
. ($use_captcha ? ' https://www.google.com' : ' ')
. ";"
);
header(
"X-Content-Security-Policy: default-src 'self' "
. ($use_captcha ? 'https://www.google.com ' : ' ')
Expand Down

0 comments on commit 5199ad8

Please sign in to comment.