mirror of https://github.com/gorhill/uBlock.git
code review re. 60f60c2c97
This commit is contained in:
parent
35b46cab4c
commit
d4ce29397a
|
@ -55,7 +55,7 @@ var ThirdParty = 2 << 2;
|
|||
|
||||
var AnyType = 0 << 4;
|
||||
var typeNameToTypeValue = {
|
||||
'notype': 0 << 4,
|
||||
'no_type': 0 << 4,
|
||||
'stylesheet': 1 << 4,
|
||||
'image': 2 << 4,
|
||||
'object': 3 << 4,
|
||||
|
@ -2336,8 +2336,8 @@ FilterContainer.prototype.matchTokens = function(bucket, url) {
|
|||
|
||||
FilterContainer.prototype.matchStringExactType = function(context, requestURL, requestType) {
|
||||
// Be prepared to support unknown types
|
||||
var type = typeNameToTypeValue[requestType] || 0;
|
||||
if ( type === 0 ) {
|
||||
var type = typeNameToTypeValue[requestType];
|
||||
if ( type === undefined ) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
@ -2436,7 +2436,7 @@ FilterContainer.prototype.matchString = function(context) {
|
|||
var type = typeNameToTypeValue[context.requestType];
|
||||
if ( type === undefined ) {
|
||||
type = typeOtherValue;
|
||||
} else if ( type > typeOtherValue ) {
|
||||
} else if ( type === 0 || type > typeOtherValue ) {
|
||||
return this.matchStringExactType(context, context.requestURL, context.requestType);
|
||||
}
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ var onBeforeRootFrameRequest = function(details) {
|
|||
pageDomain: requestDomain,
|
||||
requestURL: requestURL,
|
||||
requestHostname: requestHostname,
|
||||
requestType: 'notype'
|
||||
requestType: 'main_frame'
|
||||
};
|
||||
|
||||
var result = '';
|
||||
|
@ -196,12 +196,18 @@ var onBeforeRootFrameRequest = function(details) {
|
|||
var snfe = µb.staticNetFilteringEngine;
|
||||
|
||||
// Check for specific block
|
||||
if ( result === '' && snfe.matchStringExactType(context, requestURL, 'main_frame') !== undefined ) {
|
||||
if (
|
||||
result === '' &&
|
||||
snfe.matchStringExactType(context, requestURL, 'main_frame') !== undefined
|
||||
) {
|
||||
result = snfe.toResultString(true);
|
||||
}
|
||||
|
||||
// Check for generic block
|
||||
if ( result === '' && snfe.matchString(context) !== undefined ) {
|
||||
if (
|
||||
result === '' &&
|
||||
snfe.matchStringExactType(context, requestURL, 'no_type') !== undefined
|
||||
) {
|
||||
result = snfe.toResultString(true);
|
||||
// https://github.com/chrisaljoudi/uBlock/issues/1128
|
||||
// Do not block if the match begins after the hostname, except when
|
||||
|
|
Loading…
Reference in New Issue