Skip to content

Commit

Permalink
Enable the blocking of CSP reports by default
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Dec 11, 2020
1 parent d0a0984 commit 7d90f97
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/js/hnswitches.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

/******************************************************************************/

µBlock.HnSwitches = (function() {
µBlock.HnSwitches = (( ) => {

/******************************************************************************/

Expand Down
32 changes: 8 additions & 24 deletions src/js/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,33 +111,16 @@ const onVersionReady = function(lastVersion) {
µb.redirectEngine.invalidateResourcesSelfie();

const lastVersionInt = vAPI.app.intFromVersion(lastVersion);
if ( lastVersionInt === 0 ) { return; }

// https://github.com/uBlockOrigin/uBlock-issues/issues/494
// Remove useless per-site switches.
if ( lastVersionInt <= 1019003007 ) {
µb.sessionSwitches.toggle('no-scripting', 'behind-the-scene', 0);
µb.permanentSwitches.toggle('no-scripting', 'behind-the-scene', 0);
// https://github.com/LiCybora/NanoDefenderFirefox/issues/196
// Toggle on the blocking of CSP reports by default.
if ( lastVersionInt <= 1031003011 ) {
µb.sessionSwitches.toggle('no-csp-reports', '*', 1);
µb.permanentSwitches.toggle('no-csp-reports', '*', 1);
µb.saveHostnameSwitches();
}

// Configure new popup panel according to classic popup panel
// configuration.
if ( lastVersionInt !== 0 ) {
if ( lastVersionInt <= 1026003014 ) {
µb.userSettings.popupPanelSections =
µb.userSettings.dynamicFilteringEnabled === true ? 0b11111 : 0b01111;
µb.userSettings.dynamicFilteringEnabled = undefined;
µb.saveUserSettings();
} else if (
lastVersionInt <= 1026003016 &&
(µb.userSettings.popupPanelSections & 1) !== 0
) {
µb.userSettings.popupPanelSections =
(µb.userSettings.popupPanelSections << 1 | 1) & 0b111111;
µb.saveUserSettings();
}
}

vAPI.storage.set({ version: vAPI.app.version });
};

Expand Down Expand Up @@ -240,13 +223,14 @@ const fromFetch = function(to, fetched) {
const createDefaultProps = function() {
const fetchableProps = {
'dynamicFilteringString': [
'no-csp-reports: * true',
'behind-the-scene * * noop',
'behind-the-scene * image noop',
'behind-the-scene * 3p noop',
'behind-the-scene * inline-script noop',
'behind-the-scene * 1p-script noop',
'behind-the-scene * 3p-script noop',
'behind-the-scene * 3p-frame noop'
'behind-the-scene * 3p-frame noop',
].join('\n'),
'urlFilteringString': '',
'hostnameSwitchesString': [
Expand Down

4 comments on commit 7d90f97

@gwarser
Copy link
Contributor

@gwarser gwarser commented on 7d90f97 Dec 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How it is supposed to work? Resetting or reinstalling v1.31.3b14 on Chrome/Firefox - preference is not set.

    if ( lastVersionInt <= 1031003011 ) {

Updating from version below 1.31.3b11 should make it work? Should toggle the switch if set, but defaults are in line 226... ?

@gorhill
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this, mistake in where I declared the switch state.

@gwarser
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gorhill
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Giving more thoughts to this, in the next revision I will limit the enabling to Firefox platform since the issue does not affect Chromium-based browsers.

Please sign in to comment.