Skip to content

Commit

Permalink
Fix CSP/PP header injection in non-document resources
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jul 10, 2024
1 parent 9c1252e commit c90f493
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/js/traffic.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,16 @@ const onHeadersReceived = function(details) {
if ( httpheaderFilteringEngine.apply(fctxt, responseHeaders) === true ) {
modifiedHeaders = true;
}
if ( injectCSP(fctxt, pageStore, responseHeaders) === true ) {
modifiedHeaders = true;
}
if ( injectPP(fctxt, pageStore, responseHeaders) === true ) {
modifiedHeaders = true;

// https://github.com/uBlockOrigin/uBlock-issues/issues/229#issuecomment-2220354261
// Inject CSP/PP in document resource only
if ( fctxt.isDocument() ) {
if ( injectCSP(fctxt, pageStore, responseHeaders) === true ) {
modifiedHeaders = true;
}
if ( injectPP(fctxt, pageStore, responseHeaders) === true ) {
modifiedHeaders = true;
}
}

// https://bugzilla.mozilla.org/show_bug.cgi?id=1376932
Expand Down Expand Up @@ -945,10 +950,6 @@ const bodyFilterer = (( ) => {
/******************************************************************************/

const injectCSP = function(fctxt, pageStore, responseHeaders) {
// https://github.com/uBlockOrigin/uBlock-issues/issues/229#issuecomment-2220354261
// Inject CSP in document resource only
if ( fctxt.isDocument() === false ) { return; }

const cspSubsets = [];
const requestType = fctxt.type;

Expand Down

0 comments on commit c90f493

Please sign in to comment.