Skip to content

Commit

Permalink
Store csp= filters into main data structure
Browse files Browse the repository at this point in the history
This commits make it so that `csp=` filters
are now stored in the same data structures as
all other static network filters rather than
being stored in a separate one.

This internal change is motivated by the wish
to bring session filters to the static network
filtering engine, as has already been done for
the static extended filtering engine in the
following commit:

59c9a34
  • Loading branch information
gorhill committed Sep 28, 2019
1 parent 235851d commit 4bf6503
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 153 deletions.
2 changes: 1 addition & 1 deletion src/js/background.js
Expand Up @@ -142,7 +142,7 @@ const µBlock = (( ) => { // jshint ignore:line
// Read-only
systemSettings: {
compiledMagic: 21, // Increase when compiled format changes
selfieMagic: 21, // Increase when selfie format changes
selfieMagic: 22, // Increase when selfie format changes
},

restoreBackupSettings: {
Expand Down
17 changes: 6 additions & 11 deletions src/js/messaging.js
Expand Up @@ -1478,18 +1478,13 @@ const logCSPViolations = function(pageStore, request) {
if ( cspData === undefined ) {
cspData = new Map();

const policies = [];
const logData = [];
µb.staticNetFilteringEngine.matchAndFetchData(
'csp',
request.docURL,
policies,
logData
);
for ( let i = 0; i < policies.length; i++ ) {
cspData.set(policies[i], logData[i]);
const staticDirectives =
µb.staticNetFilteringEngine.matchAndFetchData(fctxt, 'csp');
for ( const directive of staticDirectives ) {
if ( directive.result !== 1 ) { continue; }
cspData.set(directive.data, directive.logData());
}

fctxt.type = 'inline-script';
fctxt.filter = undefined;
if ( pageStore.filterRequest(fctxt) === 1 ) {
Expand Down

0 comments on commit 4bf6503

Please sign in to comment.