Skip to content

Commit 8cbee1f

Browse files
committed
fixup! add Reporting-Endpoints header; add report-uri as well
1 parent 92228a4 commit 8cbee1f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

themes/jquery/functions.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ function jq_content_security_policy() {
260260
return;
261261
}
262262
$nonce = bin2hex( random_bytes( 8 ) );
263+
$report_url = 'https://csp-report-api.openjs-foundation.workers.dev/';
263264
$policy = array(
264265
'default-src' => "'self'",
265266
'script-src' => "'self' 'nonce-$nonce' code.jquery.com",
@@ -277,7 +278,10 @@ function jq_content_security_policy() {
277278
'frame-ancestors' => "'none'",
278279
'base-uri' => "'self'",
279280
'block-all-mixed-content' => '',
280-
'report-to' => 'https://csp-report-api.openjs-foundation.workers.dev/',
281+
'report-to' => 'csp-endpoint',
282+
// Add report-uri for Firefox, which
283+
// does not yet support report-to
284+
'report-uri' => $report_url,
281285
);
282286

283287
$policy = apply_filters( 'jq_content_security_policy', $policy );
@@ -287,6 +291,7 @@ function jq_content_security_policy() {
287291
$policy_string .= $key . ' ' . $value . '; ';
288292
}
289293

294+
header( 'Reporting-Endpoints: csp-endpoint="' . $report_url . '"' );
290295
header( 'Content-Security-Policy-Report-Only: ' . $policy_string );
291296
}
292297

0 commit comments

Comments
 (0)