Skip to content

Commit

Permalink
this completely fixes #490
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jul 13, 2015
1 parent afb0755 commit fa4e3ca
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/js/logger-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ var filterDecompiler = (function() {
6: 'subdocument',
7: 'font',
8: 'other',
12: 'document',
13: 'elemhide',
14: 'inline-script',
15: 'popup'
Expand Down
19 changes: 13 additions & 6 deletions src/js/static-net-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -1278,7 +1281,7 @@ FilterParser.prototype.parseOptType = function(raw, not) {
this.types = allNetRequestTypesBitmap;
}

this.types &= ~typeBit;
this.types &= ~typeBit & allNetRequestTypesBitmap;
};

/******************************************************************************/
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
10 changes: 8 additions & 2 deletions src/js/traffic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fa4e3ca

Please sign in to comment.