mirror of https://github.com/gorhill/uBlock.git
fix #1779: do not give up scanning the list if first match turns out negative
This commit is contained in:
parent
0fa552670a
commit
b9d1cd54bc
|
@ -41,7 +41,6 @@ var reSpecialChars = /[\*\^\t\v\n]/;
|
|||
|
||||
var fromNetFilter = function(details) {
|
||||
var lists = [];
|
||||
|
||||
var compiledFilter = details.compiledFilter;
|
||||
var entry, content, pos, c;
|
||||
for ( var path in listEntries ) {
|
||||
|
@ -50,24 +49,27 @@ var fromNetFilter = function(details) {
|
|||
continue;
|
||||
}
|
||||
content = entry.content;
|
||||
pos = content.indexOf(compiledFilter);
|
||||
if ( pos === -1 ) {
|
||||
continue;
|
||||
pos = 0;
|
||||
for (;;) {
|
||||
pos = content.indexOf(compiledFilter, pos);
|
||||
if ( pos === -1 ) {
|
||||
break;
|
||||
}
|
||||
// We need an exact match.
|
||||
// https://github.com/gorhill/uBlock/issues/1392
|
||||
// https://github.com/gorhill/uBlock/issues/835
|
||||
if ( pos === 0 || reSpecialChars.test(content.charAt(pos - 1)) ) {
|
||||
c = content.charAt(pos + compiledFilter.length);
|
||||
if ( c === '' || reSpecialChars.test(c) ) {
|
||||
lists.push({
|
||||
title: entry.title,
|
||||
supportURL: entry.supportURL
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
pos += compiledFilter.length;
|
||||
}
|
||||
// We need an exact match.
|
||||
// https://github.com/gorhill/uBlock/issues/1392
|
||||
if ( pos !== 0 && reSpecialChars.test(content.charAt(pos - 1)) === false ) {
|
||||
continue;
|
||||
}
|
||||
// https://github.com/gorhill/uBlock/issues/835
|
||||
c = content.charAt(pos + compiledFilter.length);
|
||||
if ( c !== '' && reSpecialChars.test(c) === false ) {
|
||||
continue;
|
||||
}
|
||||
lists.push({
|
||||
title: entry.title,
|
||||
supportURL: entry.supportURL
|
||||
});
|
||||
}
|
||||
|
||||
var response = {};
|
||||
|
|
Loading…
Reference in New Issue