mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-06 02:42:33 +01:00
This commit is contained in:
parent
e8e1b9eb07
commit
4da20e96e7
@ -1205,6 +1205,10 @@ FilterPair.prototype.remove = function(fdata) {
|
|||||||
if ( arrayStrictEquals(this.f1.compile(), fdata) === true ) {
|
if ( arrayStrictEquals(this.f1.compile(), fdata) === true ) {
|
||||||
this.f1 = this.f2;
|
this.f1 = this.f2;
|
||||||
}
|
}
|
||||||
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/84
|
||||||
|
if ( this.f1 === undefined ) {
|
||||||
|
console.log(JSON.stringify(fdata));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
FilterPair.prototype.match = function(url, tokenBeg) {
|
FilterPair.prototype.match = function(url, tokenBeg) {
|
||||||
@ -1229,11 +1233,17 @@ FilterPair.prototype.compile = function() {
|
|||||||
|
|
||||||
FilterPair.prototype.upgrade = function(a) {
|
FilterPair.prototype.upgrade = function(a) {
|
||||||
var bucket = new FilterBucket(this.f1, this.f2, a);
|
var bucket = new FilterBucket(this.f1, this.f2, a);
|
||||||
this.f1 = this.f2 = this.f = null;
|
this.f1 = this.f2 = undefined;
|
||||||
|
this.f = null;
|
||||||
FilterPair.available = this;
|
FilterPair.available = this;
|
||||||
return bucket;
|
return bucket;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FilterPair.prototype.downgrade = function() {
|
||||||
|
if ( this.f2 !== undefined ) { return this; }
|
||||||
|
if ( this.f1 !== undefined ) { return this.f1; }
|
||||||
|
};
|
||||||
|
|
||||||
FilterPair.load = function(args) {
|
FilterPair.load = function(args) {
|
||||||
var f1 = filterFromCompiledData(args[1]),
|
var f1 = filterFromCompiledData(args[1]),
|
||||||
f2 = filterFromCompiledData(args[2]),
|
f2 = filterFromCompiledData(args[2]),
|
||||||
@ -1329,7 +1339,11 @@ FilterBucket.prototype.compile = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
FilterBucket.prototype.downgrade = function() {
|
FilterBucket.prototype.downgrade = function() {
|
||||||
|
if ( this.filters.length > 2 ) { return this; }
|
||||||
|
if ( this.filters.length === 2 ) {
|
||||||
return new FilterPair(this.filters[0], this.filters[1]);
|
return new FilterPair(this.filters[0], this.filters[1]);
|
||||||
|
}
|
||||||
|
if ( this.filters.length === 1 ) { return this.filters[0]; }
|
||||||
};
|
};
|
||||||
|
|
||||||
FilterBucket.load = function(args) {
|
FilterBucket.load = function(args) {
|
||||||
@ -2371,37 +2385,25 @@ FilterContainer.prototype.removeBadFilters = function() {
|
|||||||
entry = bucket.get(tokenHash);
|
entry = bucket.get(tokenHash);
|
||||||
if ( entry === undefined ) { continue; }
|
if ( entry === undefined ) { continue; }
|
||||||
fdata = args[2];
|
fdata = args[2];
|
||||||
if ( entry.fid === filterPairId ) {
|
if ( entry.fid === filterPairId || entry.fid === filterBucketId ) {
|
||||||
entry.remove(fdata);
|
entry.remove(fdata);
|
||||||
if ( entry.size === 1 ) {
|
entry = entry.downgrade();
|
||||||
bucket.set(tokenHash, entry.f1);
|
if ( entry !== undefined ) {
|
||||||
|
bucket.set(tokenHash, entry);
|
||||||
|
} else {
|
||||||
|
bucket.delete(tokenHash);
|
||||||
}
|
}
|
||||||
continue;
|
} else if ( entry.fid === filterHostnameDictId ) {
|
||||||
}
|
|
||||||
if ( entry.fid === filterBucketId ) {
|
|
||||||
entry.remove(fdata);
|
|
||||||
if ( entry.size === 2 ) {
|
|
||||||
bucket.set(tokenHash, entry.downgrade());
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ( entry.fid === filterHostnameDictId ) {
|
|
||||||
entry.remove(fdata);
|
entry.remove(fdata);
|
||||||
if ( entry.size === 0 ) {
|
if ( entry.size === 0 ) {
|
||||||
bucket.delete(tokenHash);
|
bucket.delete(tokenHash);
|
||||||
if ( bucket.size === 0 ) {
|
|
||||||
this.categories.delete(bits);
|
|
||||||
}
|
}
|
||||||
}
|
} else if ( arrayStrictEquals(entry.compile(), fdata) ) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ( arrayStrictEquals(entry.compile(), fdata) === true ) {
|
|
||||||
bucket.delete(tokenHash);
|
bucket.delete(tokenHash);
|
||||||
|
}
|
||||||
if ( bucket.size === 0 ) {
|
if ( bucket.size === 0 ) {
|
||||||
this.categories.delete(bits);
|
this.categories.delete(bits);
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user