mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-07 03:12:33 +01:00
fix #3494
This commit is contained in:
parent
8b538de0cd
commit
959f68ce89
@ -115,13 +115,13 @@ var fromNetFilter = function(details) {
|
|||||||
var fromCosmeticFilter = function(details) {
|
var fromCosmeticFilter = function(details) {
|
||||||
var match = /^#@?#\^?/.exec(details.rawFilter),
|
var match = /^#@?#\^?/.exec(details.rawFilter),
|
||||||
prefix = match[0],
|
prefix = match[0],
|
||||||
|
exception = prefix.charAt(1) === '@',
|
||||||
selector = details.rawFilter.slice(prefix.length);
|
selector = details.rawFilter.slice(prefix.length);
|
||||||
|
|
||||||
// The longer the needle, the lower the number of false positives.
|
// The longer the needle, the lower the number of false positives.
|
||||||
var needles = selector.match(/\w+/g).sort(function(a, b) {
|
var needle = selector.match(/\w+/g).reduce(function(a, b) {
|
||||||
return b.length - a.length;
|
return a.length > b.length ? a : b;
|
||||||
});
|
});
|
||||||
var reNeedle = new RegExp(needles[0], 'g');
|
|
||||||
|
|
||||||
var reHostname = new RegExp(
|
var reHostname = new RegExp(
|
||||||
'^' +
|
'^' +
|
||||||
@ -163,12 +163,14 @@ var fromCosmeticFilter = function(details) {
|
|||||||
entry = listEntries[assetKey];
|
entry = listEntries[assetKey];
|
||||||
if ( entry === undefined ) { continue; }
|
if ( entry === undefined ) { continue; }
|
||||||
content = extractBlocks(entry.content, 1000, 2000);
|
content = extractBlocks(entry.content, 1000, 2000);
|
||||||
|
pos = 0;
|
||||||
found = undefined;
|
found = undefined;
|
||||||
while ( (match = reNeedle.exec(content)) !== null ) {
|
while ( (pos = content.indexOf(needle, pos)) !== -1 ) {
|
||||||
beg = content.lastIndexOf('\n', match.index);
|
beg = content.lastIndexOf('\n', pos);
|
||||||
if ( beg === -1 ) { beg = 0; }
|
if ( beg === -1 ) { beg = 0; }
|
||||||
end = content.indexOf('\n', reNeedle.lastIndex);
|
end = content.indexOf('\n', pos);
|
||||||
if ( end === -1 ) { end = content.length; }
|
if ( end === -1 ) { end = content.length; }
|
||||||
|
pos = end;
|
||||||
fargs = JSON.parse(content.slice(beg, end));
|
fargs = JSON.parse(content.slice(beg, end));
|
||||||
switch ( fargs[0] ) {
|
switch ( fargs[0] ) {
|
||||||
case 0: // id-based
|
case 0: // id-based
|
||||||
@ -215,6 +217,9 @@ var fromCosmeticFilter = function(details) {
|
|||||||
case 32:
|
case 32:
|
||||||
case 64:
|
case 64:
|
||||||
case 65:
|
case 65:
|
||||||
|
if ( exception !== (fargs[1].charAt(0) === '!') ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
isProcedural = fargs[3].charCodeAt(0) === 0x7B;
|
isProcedural = fargs[3].charCodeAt(0) === 0x7B;
|
||||||
if (
|
if (
|
||||||
isProcedural === false && fargs[3] !== selector ||
|
isProcedural === false && fargs[3] !== selector ||
|
||||||
|
Loading…
Reference in New Issue
Block a user