mirror of
https://github.com/gorhill/uBlock.git
synced 2025-01-31 20:21:35 +01:00
Add advanced setting noScriptingCSP
Related discussion: https://github.com/uBlockOrigin/uBlock-issues/issues/2642#issuecomment-2520096503 Specify which CSP directive to inject when no-scripting switch is toggled on. If this hidden setting is changed, uBO will not try to spoof `noscript` elements. For internal use at the moment, not to be documented.
This commit is contained in:
parent
f80143a8ee
commit
a86e802afc
@ -73,6 +73,7 @@ const hiddenSettingsDefault = {
|
||||
loggerPopupType: 'popup',
|
||||
manualUpdateAssetFetchPeriod: 500,
|
||||
modifyWebextFlavor: 'unset',
|
||||
noScriptingCSP: 'script-src http: https:',
|
||||
popupFontSize: 'unset',
|
||||
popupPanelDisabledSections: 0,
|
||||
popupPanelHeightMode: 0,
|
||||
@ -254,7 +255,6 @@ const µBlock = { // jshint ignore:line
|
||||
scriptlets: {},
|
||||
|
||||
cspNoInlineScript: "script-src 'unsafe-eval' * blob: data:",
|
||||
cspNoScripting: 'script-src http: https:',
|
||||
cspNoInlineFont: 'font-src *',
|
||||
|
||||
liveBlockingProfiles: [],
|
||||
|
@ -804,6 +804,9 @@ const onMessage = function(request, sender, callback) {
|
||||
|
||||
case 'shouldRenderNoscriptTags': {
|
||||
if ( pageStore === null ) { break; }
|
||||
if ( µb.hiddenSettings.noScriptingCSP !== µb.hiddenSettingsDefault.noScriptingCSP ) {
|
||||
break;
|
||||
}
|
||||
const fctxt = µb.filteringContext.fromTabId(sender.tabId);
|
||||
if ( pageStore.filterScripting(fctxt, undefined) ) {
|
||||
vAPI.tabs.executeScript(sender.tabId, {
|
||||
@ -2009,7 +2012,7 @@ const logCSPViolations = function(pageStore, request) {
|
||||
fctxt.type = 'script';
|
||||
fctxt.filter = undefined;
|
||||
if ( pageStore.filterScripting(fctxt, true) === 1 ) {
|
||||
cspData.set(µb.cspNoScripting, fctxt.filter);
|
||||
cspData.set(µb.hiddenSettings.noScriptingCSP, fctxt.filter);
|
||||
}
|
||||
|
||||
fctxt.type = 'inline-font';
|
||||
|
@ -969,7 +969,7 @@ const injectCSP = function(fctxt, pageStore, responseHeaders) {
|
||||
const builtinDirectives = [];
|
||||
|
||||
if ( pageStore.filterScripting(fctxt, true) === 1 ) {
|
||||
builtinDirectives.push(µb.cspNoScripting);
|
||||
builtinDirectives.push(µb.hiddenSettings.noScriptingCSP);
|
||||
if ( logger.enabled ) {
|
||||
fctxt.setRealm('network').setType('scripting').toLogger();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user