This commit is contained in:
Raymond Hill 2018-03-13 17:24:07 -04:00
parent 796152c528
commit 04cee142bc
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 7 additions and 14 deletions

View File

@ -1073,24 +1073,17 @@ var injectCSP = function(pageStore, details) {
µb.updateBadgeAsync(tabId);
var csp,
headers = details.responseHeaders,
i = headerIndexFromName('content-security-policy', headers);
if ( i !== -1 ) {
csp = headers[i].value.trim();
headers.splice(i, 1);
}
cspSubsets = cspSubsets.join(', ');
// Use comma to add a new subset to potentially existing one(s). This new
// subset has its own reporting options and won't cause spurious CSP
// reports to outside world.
// Use comma to merge CSP directives.
// Ref.: https://www.w3.org/TR/CSP2/#implementation-considerations
headers.push({
//
// https://github.com/gorhill/uMatrix/issues/967
// Inject a new CSP header rather than modify an existing one.
details.responseHeaders.push({
name: 'Content-Security-Policy',
value: csp === undefined ? cspSubsets : csp + ', ' + cspSubsets
value: cspSubsets.join(', ')
});
return { 'responseHeaders': headers };
return { 'responseHeaders': details.responseHeaders };
};
/******************************************************************************/