From 0adae9fb65a4b58c33d96aedb997de196ab020e7 Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 17 Feb 2016 09:28:20 -0500 Subject: [PATCH] this fixes #1395 --- src/js/messaging.js | 4 ++-- src/js/storage.js | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/js/messaging.js b/src/js/messaging.js index fd13e59c0..2ea75fa94 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -1123,7 +1123,7 @@ var backupUserData = function(callback) { µb.extractSelectedFilterLists(onSelectedListsReady); }; - µb.assets.get('assets/user/filters.txt', onUserFiltersReady); + µb.assets.get(µb.userFiltersPath, onUserFiltersReady); }; /******************************************************************************/ @@ -1153,7 +1153,7 @@ var restoreUserData = function(request) { µb.keyvalSetOne('urlFilteringString', userData.urlFilteringString || '', onCountdown); µb.keyvalSetOne('hostnameSwitchesString', userData.hostnameSwitchesString || '', onCountdown); - µb.assets.put('assets/user/filters.txt', userData.userFilters, onCountdown); + µb.assets.put(µb.userFiltersPath, userData.userFilters, onCountdown); vAPI.storage.set({ lastRestoreFile: request.file || '', lastRestoreTime: Date.now(), diff --git a/src/js/storage.js b/src/js/storage.js index 08152d1d8..3e626525d 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -181,7 +181,7 @@ var cfe = µb.cosmeticFilteringEngine; var acceptedCount = snfe.acceptedCount + cfe.acceptedCount; var duplicateCount = snfe.duplicateCount + cfe.duplicateCount; - µb.applyCompiledFilters(compiledFilters); + µb.applyCompiledFilters(compiledFilters, true); var entry = µb.remoteBlacklists[µb.userFiltersPath]; var deltaEntryCount = snfe.acceptedCount + cfe.acceptedCount - acceptedCount; var deltaEntryUsedCount = deltaEntryCount - (snfe.duplicateCount + cfe.duplicateCount - duplicateCount); @@ -418,7 +418,7 @@ var cfe = µb.cosmeticFilteringEngine; var acceptedCount = snfe.acceptedCount + cfe.acceptedCount; var duplicateCount = snfe.duplicateCount + cfe.duplicateCount; - µb.applyCompiledFilters(compiled); + µb.applyCompiledFilters(compiled, path === µb.userFiltersPath); if ( µb.remoteBlacklists.hasOwnProperty(path) ) { var entry = µb.remoteBlacklists[path]; entry.entryCount = snfe.acceptedCount + cfe.acceptedCount - acceptedCount; @@ -627,8 +627,12 @@ /******************************************************************************/ -µBlock.applyCompiledFilters = function(rawText) { - var skipCosmetic = !this.userSettings.parseAllABPHideFilters; +// https://github.com/gorhill/uBlock/issues/1395 +// Added `firstparty` argument: to avoid discarding cosmetic filtering when +// applying 1st-party filters. + +µBlock.applyCompiledFilters = function(rawText, firstparty) { + var skipCosmetic = !firstparty && !this.userSettings.parseAllABPHideFilters; var staticNetFilteringEngine = this.staticNetFilteringEngine; var cosmeticFilteringEngine = this.cosmeticFilteringEngine; var lineBeg = 0; @@ -864,7 +868,7 @@ } if ( typeof data.userFilters === 'string' ) { - µb.assets.put('assets/user/filters.txt', data.userFilters); + µb.assets.put(µb.userFiltersPath, data.userFilters); } callback();