3 namespace dokuwiki\HTTP
;
6 * Utilities to send HTTP Headers
11 * Send a Content-Security-Polica Header
13 * Expects an associative array with individual policies and their values
15 * @param array $policy
17 public static function contentSecurityPolicy($policy)
19 foreach ($policy as $key => $values) {
20 // if the value is not an array, we also accept newline terminated strings
21 if (!is_array($values)) $values = explode("\n", $values);
22 $values = array_map('trim', $values);
23 $values = array_unique($values);
24 $values = array_filter($values);
25 $policy[$key] = $values;
28 $cspheader = 'Content-Security-Policy:';
29 foreach ($policy as $key => $values) {
31 $cspheader .= " $key " . implode(' ', $values) . ';';
33 $cspheader .= " $key;";