1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-05 11:37:01 +02:00
This commit is contained in:
gorhill 2017-09-11 09:53:42 -04:00
parent 462406ecf1
commit dfe18111b9
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 30 additions and 9 deletions

View File

@ -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();

View File

@ -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.