mirror of https://github.com/gorhill/uBlock.git
fix #3150
This commit is contained in:
parent
143e9c7414
commit
95b25f7d49
|
@ -251,6 +251,10 @@
|
|||
"message":"Block remote fonts",
|
||||
"description": ""
|
||||
},
|
||||
"settingsNoCSPReportsPrompt":{
|
||||
"message":"Block CSP reports",
|
||||
"description": ""
|
||||
},
|
||||
"settingsStorageUsed":{
|
||||
"message":"Storage used: {{value}} bytes",
|
||||
"description":"English: Storage used: {{}} bytes"
|
||||
|
|
|
@ -41,15 +41,8 @@ var switchBitOffsets = {
|
|||
'no-popups': 2,
|
||||
'no-cosmetic-filtering': 4,
|
||||
'no-remote-fonts': 6,
|
||||
'no-large-media': 8
|
||||
};
|
||||
|
||||
var fromLegacySwitchNames = {
|
||||
'dontBlockDoc': 'no-strict-blocking',
|
||||
'doBlockAllPopups': 'no-popups',
|
||||
'noStrictBlocking': 'no-strict-blocking',
|
||||
'noPopups': 'no-popups',
|
||||
'noCosmeticFiltering': 'no-cosmetic-filtering'
|
||||
'no-large-media': 8,
|
||||
'no-csp-reports': 10
|
||||
};
|
||||
|
||||
var switchStateToNameMap = {
|
||||
|
@ -315,7 +308,6 @@ HnSwitches.prototype.fromString = function(text) {
|
|||
continue;
|
||||
}
|
||||
switchName = switchName.slice(0, pos);
|
||||
switchName = fromLegacySwitchNames[switchName] || switchName;
|
||||
if ( switchBitOffsets.hasOwnProperty(switchName) === false ) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -589,37 +589,13 @@ PageStore.prototype.filterRequest = function(context) {
|
|||
|
||||
var requestType = context.requestType;
|
||||
|
||||
// https://github.com/gorhill/uBlock/issues/3140
|
||||
// Special handling of CSP reports if and only if these can't be filtered
|
||||
// natively.
|
||||
if (
|
||||
requestType === 'csp_report' &&
|
||||
vAPI.net.nativeCSPReportFiltering !== true
|
||||
) {
|
||||
if ( this.internalRedirectionCount !== 0 ) {
|
||||
if ( µb.logger.isEnabled() ) {
|
||||
this.logData = {
|
||||
result: 1,
|
||||
source: 'global',
|
||||
raw: 'no-spurious-csp-report'
|
||||
};
|
||||
}
|
||||
if ( requestType === 'csp_report' && this.filterCSPReport(context) === 1 ) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( requestType.endsWith('font') ) {
|
||||
if ( requestType === 'font' ) {
|
||||
this.remoteFontCount += 1;
|
||||
}
|
||||
if ( µb.hnSwitches.evaluateZ('no-remote-fonts', context.rootHostname) !== false ) {
|
||||
if ( µb.logger.isEnabled() ) {
|
||||
this.logData = µb.hnSwitches.toLogData();
|
||||
}
|
||||
if ( requestType.endsWith('font') && this.filterFont(context) === 1 ) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
var cacheableResult = this.cacheableResults[requestType] === true;
|
||||
|
||||
|
@ -675,6 +651,49 @@ PageStore.prototype.collapsibleResources = {
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
PageStore.prototype.filterCSPReport = function(context) {
|
||||
if ( µb.hnSwitches.evaluateZ('no-csp-reports', context.rootHostname) !== false ) {
|
||||
if ( µb.logger.isEnabled() ) {
|
||||
this.logData = µb.hnSwitches.toLogData();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
// https://github.com/gorhill/uBlock/issues/3140
|
||||
// Special handling of CSP reports if and only if these can't be filtered
|
||||
// natively.
|
||||
if (
|
||||
vAPI.net.nativeCSPReportFiltering !== true &&
|
||||
this.internalRedirectionCount !== 0
|
||||
) {
|
||||
if ( µb.logger.isEnabled() ) {
|
||||
this.logData = {
|
||||
result: 1,
|
||||
source: 'global',
|
||||
raw: 'no-spurious-csp-report'
|
||||
};
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
PageStore.prototype.filterFont = function(context) {
|
||||
if ( context.requestType === 'font' ) {
|
||||
this.remoteFontCount += 1;
|
||||
}
|
||||
if ( µb.hnSwitches.evaluateZ('no-remote-fonts', context.rootHostname) !== false ) {
|
||||
if ( µb.logger.isEnabled() ) {
|
||||
this.logData = µb.hnSwitches.toLogData();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// The caller is responsible to check whether filtering is enabled or not.
|
||||
|
||||
PageStore.prototype.filterLargeMediaElement = function(size) {
|
||||
|
|
|
@ -353,8 +353,11 @@ var onBeforeBehindTheSceneRequest = function(details) {
|
|||
// Blocking behind-the-scene requests can break a lot of stuff: prevent
|
||||
// browser updates, prevent extension updates, prevent extensions from
|
||||
// working properly, etc.
|
||||
// So we filter if and only if the "advanced user" mode is selected
|
||||
if ( µb.userSettings.advancedUserEnabled ) {
|
||||
// So we filter if and only if the "advanced user" mode is selected.
|
||||
// https://github.com/gorhill/uBlock/issues/3150
|
||||
// Ability to globally block CSP reports MUST also apply to
|
||||
// behind-the-scene network requests.
|
||||
if ( µb.userSettings.advancedUserEnabled || requestType === 'csp_report' ) {
|
||||
result = pageStore.filterRequest(context);
|
||||
}
|
||||
|
||||
|
|
|
@ -304,6 +304,7 @@ var reInvalidHostname = /[^a-z0-9.\-\[\]:]/,
|
|||
us.noCosmeticFiltering = this.hnSwitches.evaluate('no-cosmetic-filtering', '*') === 1;
|
||||
us.noLargeMedia = this.hnSwitches.evaluate('no-large-media', '*') === 1;
|
||||
us.noRemoteFonts = this.hnSwitches.evaluate('no-remote-fonts', '*') === 1;
|
||||
us.noCSPReports = this.hnSwitches.evaluate('no-csp-reports', '*') === 1;
|
||||
return us;
|
||||
}
|
||||
|
||||
|
@ -371,6 +372,11 @@ var reInvalidHostname = /[^a-z0-9.\-\[\]:]/,
|
|||
this.saveHostnameSwitches();
|
||||
}
|
||||
break;
|
||||
case 'noCSPReports':
|
||||
if ( this.hnSwitches.toggle('no-csp-reports', '*', value ? 1 : 0) ) {
|
||||
this.saveHostnameSwitches();
|
||||
}
|
||||
break;
|
||||
case 'prefetchingDisabled':
|
||||
if ( this.privacySettingsSupported ) {
|
||||
vAPI.browserSettings.set({ 'prefetching': !value });
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
<li><input id="prefetching-disabled" type="checkbox" data-setting-name="prefetchingDisabled" data-setting-type="bool"><label data-i18n="settingsPrefetchingDisabledPrompt" for="prefetching-disabled"></label> <a class="fa info" href="https://wikipedia.org/wiki/Link_prefetching#Issues_and_criticisms" target="_blank"></a>
|
||||
<li><input id="hyperlink-auditing-disabled" type="checkbox" data-setting-name="hyperlinkAuditingDisabled" data-setting-type="bool"><label data-i18n="settingsHyperlinkAuditingDisabledPrompt" for="hyperlink-auditing-disabled"></label> <a class="fa info important" href="https://github.com/gorhill/uBlock/wiki/Disable-hyperlink-auditing-beacon" target="_blank"></a>
|
||||
<li><input id="webrtc-ipaddress-hidden" type="checkbox" data-setting-name="webrtcIPAddressHidden" data-setting-type="bool"><label data-i18n="settingsWebRTCIPAddressHiddenPrompt" for="webrtc-ipaddress-hidden"></label> <a class="fa info important" href="https://github.com/gorhill/uBlock/wiki/Prevent-WebRTC-from-leaking-local-IP-address" target="_blank"></a>
|
||||
<li><input id="no-csp-reports" type="checkbox" data-setting-name="noCSPReports" data-setting-type="bool"><label data-i18n="settingsNoCSPReportsPrompt" for="no-csp-reports"></label> <a class="fa info" href="https://github.com/gorhill/uBlock/wiki/Per-site-switches#no-csp-reports" target="_blank"></a>
|
||||
</ul>
|
||||
<li class="subgroup"><span data-i18n="settingPerSiteSwitchGroup"></span><ul>
|
||||
<li><label class="synopsis"><span data-i18n="settingPerSiteSwitchGroupSynopsis"></span> <a class="fa info" href="https://github.com/gorhill/uBlock/wiki/Per-site-switches" target="_blank"></a></label>
|
||||
|
|
Loading…
Reference in New Issue