From a307cf5e6ae9f12451beb24ebb1a1c8910ae8cf6 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 17 Dec 2020 08:12:06 -0500 Subject: [PATCH] Mind restore-from-backup for no-csp-reports rule Related commit: - https://github.com/gorhill/uBlock/commit/7d90f97aa1cbf2728508506f6dd7a75c054b85d1 --- src/js/messaging.js | 10 ++++++++++ src/js/start.js | 7 +++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/js/messaging.js b/src/js/messaging.js index 1566c709d..4021fe5d4 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -926,6 +926,16 @@ const backupUserData = async function() { const restoreUserData = async function(request) { const userData = request.userData; + // https://github.com/LiCybora/NanoDefenderFirefox/issues/196 + // Backup data could be from Chromium platform or from an older + // Firefox version. + if ( + vAPI.webextFlavor.soup.has('firefox') && + vAPI.app.intFromVersion(userData.version) <= 1031003011 + ) { + userData.hostnameSwitchesString += '\nno-csp-reports: * true'; + } + // https://github.com/chrisaljoudi/uBlock/issues/1102 // Ensure all currently cached assets are flushed from storage AND memory. µb.assets.rmrf(); diff --git a/src/js/start.js b/src/js/start.js index 7ac10c0f0..79a1a441a 100644 --- a/src/js/start.js +++ b/src/js/start.js @@ -114,8 +114,11 @@ const onVersionReady = function(lastVersion) { if ( lastVersionInt === 0 ) { return; } // https://github.com/LiCybora/NanoDefenderFirefox/issues/196 - // Toggle on the blocking of CSP reports by default. - if ( lastVersionInt <= 1031003011 ) { + // Toggle on the blocking of CSP reports by default for Firefox. + if ( + vAPI.webextFlavor.soup.has('firefox') && + lastVersionInt <= 1031003011 + ) { µb.sessionSwitches.toggle('no-csp-reports', '*', 1); µb.permanentSwitches.toggle('no-csp-reports', '*', 1); µb.saveHostnameSwitches();