this completely fixes #490

This commit is contained in:
gorhill 2015-07-13 08:49:58 -04:00
parent afb07552f6
commit fa4e3ca492
3 changed files with 22 additions and 8 deletions

View File

@ -173,6 +173,7 @@ var filterDecompiler = (function() {
6: 'subdocument',
7: 'font',
8: 'other',
12: 'document',
13: 'elemhide',
14: 'inline-script',
15: 'popup'

View File

@ -64,6 +64,7 @@ var typeNameToTypeValue = {
'sub_frame': 6 << 4,
'font': 7 << 4,
'other': 8 << 4,
'main_frame': 12 << 4,
'cosmetic-filtering': 13 << 4,
'inline-script': 14 << 4,
'popup': 15 << 4
@ -76,9 +77,10 @@ var typeValueToTypeName = {
3: 'object',
4: 'script',
5: 'xmlhttprequest',
6: 'sub_frame',
6: 'subdocument',
7: 'font',
8: 'other',
12: 'document',
13: 'cosmetic-filtering',
14: 'inline-script',
15: 'popup'
@ -1231,6 +1233,7 @@ FilterParser.prototype.toNormalizedType = {
'subdocument': 'sub_frame',
'font': 'font',
'other': 'other',
'document': 'main_frame',
'elemhide': 'cosmetic-filtering',
'inline-script': 'inline-script',
'popup': 'popup'
@ -1278,7 +1281,7 @@ FilterParser.prototype.parseOptType = function(raw, not) {
this.types = allNetRequestTypesBitmap;
}
this.types &= ~typeBit;
this.types &= ~typeBit & allNetRequestTypesBitmap;
};
/******************************************************************************/
@ -1334,6 +1337,14 @@ FilterParser.prototype.parseOptions = function(s) {
this.unsupported = true;
break;
}
if ( opt === 'document' ) {
if ( this.action === BlockAction ) {
this.parseOptType('document', not);
continue;
}
this.unsupported = true;
break;
}
if ( this.toNormalizedType.hasOwnProperty(opt) ) {
this.parseOptType(opt, not);
continue;
@ -1342,10 +1353,6 @@ FilterParser.prototype.parseOptions = function(s) {
this.parseOptHostnames(opt.slice(7));
continue;
}
if ( opt === 'popup' ) {
this.parseOptType('popup', not);
continue;
}
if ( opt === 'important' ) {
this.important = Important;
continue;

View File

@ -183,10 +183,16 @@ var onBeforeRootFrameRequest = function(details) {
}
}
// Filtering
// Static filtering: We always need the long-form result here.
var snfe = µb.staticNetFilteringEngine;
// Check for specific block
if ( result === '' && snfe.matchStringExactType(context, requestURL, 'main_frame') !== undefined ) {
result = snfe.toResultString(true);
}
// Check for generic block
if ( result === '' && snfe.matchString(context) !== undefined ) {
// We always need the long-form result here.
result = snfe.toResultString(true);
// https://github.com/chrisaljoudi/uBlock/issues/1128
// Do not block if the match begins after the hostname, except when