Skip to content

Commit 23f08f0

Browse files
committed
Add support for blocklist of filter lists
Many filter lists are known to cause serious filtering issues in uBO and are not meant to be used in uBO. Unfortunately, unwitting users keep importing these filter lists and as a result this ends up causing filtering issues for which the resolution is always to remove the incompatible filter list. Example of inconpatible filter lists: - Reek's Anti-Adblock Killer - AdBlock Warning Removal List - ABP anti-circumvention filter list uBO will use the following resource to know which filter lists are incompatible: - https://github.com/uBlockOrigin/uAssets/blob/master/filters/badlists.txt Incompatible filter lists can still be imported into uBO, useful for asset-viewing purpose, but their content will be discarded at compile time.
1 parent 57330d9 commit 23f08f0

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

assets/assets.json

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
"assets/thirdparties/publicsuffix.org/list/effective_tld_names.dat"
1717
]
1818
},
19+
"ublock-badlists": {
20+
"content": "internal",
21+
"updateAfter": 13,
22+
"contentURL": [
23+
"https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/badlists.txt",
24+
"assets/ublock/badlists.txt"
25+
]
26+
},
1927
"ublock-filters": {
2028
"content": "filters",
2129
"group": "default",

src/js/background.js

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ const µBlock = (( ) => { // jshint ignore:line
171171

172172
selectedFilterLists: [],
173173
availableFilterLists: {},
174+
badLists: new Set(),
174175

175176
// https://github.com/uBlockOrigin/uBlock-issues/issues/974
176177
// This can be used to defer filtering decision-making.

src/js/storage.js

+30-9
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,15 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
481481
let oldAvailableLists = {},
482482
newAvailableLists = {};
483483

484+
if ( this.badLists.size === 0 ) {
485+
const details = await this.assets.get('ublock-badlists');
486+
this.badLists = new Set(
487+
details.content.split(/\s*[\n\r]+\s*/).filter(a => {
488+
return a !== '' && a.startsWith('#') === false;
489+
})
490+
);
491+
}
492+
484493
// User filter list.
485494
newAvailableLists[this.userFiltersPath] = {
486495
group: 'user',
@@ -498,7 +507,7 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
498507
external: true,
499508
group: 'custom',
500509
submitter: 'user',
501-
title: ''
510+
title: '',
502511
};
503512
newAvailableLists[listKey] = entry;
504513
this.assets.registerAssetSource(listKey, entry);
@@ -705,7 +714,10 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
705714
µBlock.getCompiledFilterList = async function(assetKey) {
706715
const compiledPath = 'compiled/' + assetKey;
707716

708-
if ( this.compiledFormatChanged === false ) {
717+
if (
718+
this.compiledFormatChanged === false &&
719+
this.badLists.has(assetKey) === false
720+
) {
709721
let compiledDetails = await this.assets.get(compiledPath);
710722
if ( compiledDetails.content !== '' ) {
711723
compiledDetails.assetKey = assetKey;
@@ -722,6 +734,11 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
722734

723735
this.extractFilterListMetadata(assetKey, rawDetails.content);
724736

737+
// Skip compiling bad lists.
738+
if ( this.badLists.has(assetKey) ) {
739+
return { assetKey, content: '' };
740+
}
741+
725742
// Fetching the raw content may cause the compiled content to be
726743
// generated somewhere else in uBO, hence we try one last time to
727744
// fetch the compiled content in case it has become available.
@@ -1339,13 +1356,15 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
13391356
details.assetKey,
13401357
details.content
13411358
);
1342-
this.assets.put(
1343-
'compiled/' + details.assetKey,
1344-
this.compileFilters(
1345-
details.content,
1346-
{ assetKey: details.assetKey }
1347-
)
1348-
);
1359+
if ( this.badLists.has(details.assetKey) === false ) {
1360+
this.assets.put(
1361+
'compiled/' + details.assetKey,
1362+
this.compileFilters(
1363+
details.content,
1364+
{ assetKey: details.assetKey }
1365+
)
1366+
);
1367+
}
13491368
}
13501369
} else {
13511370
this.removeCompiledFilterList(details.assetKey);
@@ -1354,6 +1373,8 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
13541373
if ( cached ) {
13551374
this.compilePublicSuffixList(details.content);
13561375
}
1376+
} else if ( details.assetKey === 'ublock-badlists' ) {
1377+
this.badLists = new Set();
13571378
}
13581379
vAPI.messaging.broadcast({
13591380
what: 'assetUpdated',

0 commit comments

Comments
 (0)