mirror of https://github.com/gorhill/uBlock.git
fix #1539
This commit is contained in:
parent
462406ecf1
commit
dfe18111b9
|
@ -598,8 +598,10 @@ PageStore.prototype.filterRequest = function(context) {
|
|||
}
|
||||
}
|
||||
|
||||
if ( requestType === 'font' ) {
|
||||
this.remoteFontCount += 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();
|
||||
|
|
|
@ -443,20 +443,17 @@ var injectCSP = function(pageStore, details) {
|
|||
if ( details.type !== 'main_frame' ) {
|
||||
context.pageHostname = context.pageDomain = context.requestHostname;
|
||||
}
|
||||
context.requestURL = requestURL;
|
||||
|
||||
// Start collecting policies >>>>>>>>
|
||||
|
||||
// ======== built-in policies
|
||||
|
||||
var builtinDirectives = [];
|
||||
|
||||
context.requestType = 'inline-script';
|
||||
context.requestURL = requestURL;
|
||||
if ( pageStore.filterRequest(context) === 1 ) {
|
||||
cspSubsets[0] = "script-src 'unsafe-eval' * blob: data:";
|
||||
// https://bugs.chromium.org/p/chromium/issues/detail?id=669086
|
||||
// TODO: remove when most users are beyond Chromium v56
|
||||
if ( vAPI.chromiumVersion < 57 ) {
|
||||
cspSubsets[0] += '; frame-src *';
|
||||
}
|
||||
builtinDirectives.push("script-src 'unsafe-eval' * blob: data:");
|
||||
}
|
||||
if ( loggerEnabled === true ) {
|
||||
logger.writeOne(
|
||||
|
@ -470,6 +467,28 @@ var injectCSP = function(pageStore, details) {
|
|||
);
|
||||
}
|
||||
|
||||
// https://github.com/gorhill/uBlock/issues/1539
|
||||
// - Use a CSP to also forbid inline fonts if remote fonts are blocked.
|
||||
context.requestType = 'inline-font';
|
||||
if ( pageStore.filterRequest(context) === 1 ) {
|
||||
builtinDirectives.push('font-src *');
|
||||
if ( loggerEnabled === true ) {
|
||||
logger.writeOne(
|
||||
tabId,
|
||||
'net',
|
||||
pageStore.logData,
|
||||
'inline-font',
|
||||
requestURL,
|
||||
context.rootHostname,
|
||||
context.pageHostname
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( builtinDirectives.length !== 0 ) {
|
||||
cspSubsets[0] = builtinDirectives.join('; ');
|
||||
}
|
||||
|
||||
// ======== filter-based policies
|
||||
|
||||
// Static filtering.
|
||||
|
|
Loading…
Reference in New Issue