mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-18 08:52:26 +02:00
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 fromNetFilter = function(details) {
|
||||||
var lists = [];
|
var lists = [];
|
||||||
|
|
||||||
var compiledFilter = details.compiledFilter;
|
var compiledFilter = details.compiledFilter;
|
||||||
var entry, content, pos, c;
|
var entry, content, pos, c;
|
||||||
for ( var path in listEntries ) {
|
for ( var path in listEntries ) {
|
||||||
@ -50,24 +49,27 @@ var fromNetFilter = function(details) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
content = entry.content;
|
content = entry.content;
|
||||||
pos = content.indexOf(compiledFilter);
|
pos = 0;
|
||||||
if ( pos === -1 ) {
|
for (;;) {
|
||||||
continue;
|
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 = {};
|
var response = {};
|
||||||
|
Loading…
Reference in New Issue
Block a user