mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-11 17:41:03 +01:00
this fixes #1093
This commit is contained in:
parent
a4169c21ad
commit
520e251112
1 changed files with 9 additions and 11 deletions
|
@ -109,22 +109,22 @@ var fromCosmeticFilter = function(details) {
|
||||||
// First step: assuming the filter is generic, find out its compiled
|
// First step: assuming the filter is generic, find out its compiled
|
||||||
// representation.
|
// representation.
|
||||||
// Reference: FilterContainer.compileGenericSelector().
|
// Reference: FilterContainer.compileGenericSelector().
|
||||||
var reStr = '';
|
var reStr = [];
|
||||||
var matches = rePlainSelector.exec(filter);
|
var matches = rePlainSelector.exec(filter);
|
||||||
if ( matches ) {
|
if ( matches ) {
|
||||||
if ( matches[0] === filter ) { // simple CSS selector
|
if ( matches[0] === filter ) { // simple CSS selector
|
||||||
reStr = reEscape('c\vlg\v' + filter);
|
reStr.push('c', 'lg', reEscape(filter));
|
||||||
} else { // complex CSS selector
|
} else { // complex CSS selector
|
||||||
reStr = reEscape('c\vlg+\v' + matches[0] + '\v' + filter);
|
reStr.push('c', reEscape('lg+'), reEscape(matches[0]), reEscape(filter));
|
||||||
}
|
}
|
||||||
} else if ( reHighLow.test(filter) ) { // [alt] or [title]
|
} else if ( reHighLow.test(filter) ) { // [alt] or [title]
|
||||||
reStr = reEscape('c\vhlg0\v' + filter);
|
reStr.push('c', 'hlg0', reEscape(filter));
|
||||||
} else if ( reHighMedium.test(filter) ) { // [href^="..."]
|
} else if ( reHighMedium.test(filter) ) { // [href^="..."]
|
||||||
reStr = reEscape('c\vhmg0\v') + '[a-z.-]+' + reEscape('\v') + '[a-z]*' + reEscape(filter);
|
reStr.push('c', 'hmg0', '[^"]{8}', '[a-z]*' + reEscape(filter));
|
||||||
} else { // all else
|
} else { // all else
|
||||||
reStr = reEscape('c\vhhg0\v' + filter);
|
reStr.push('c', 'hhg0', reEscape(filter));
|
||||||
}
|
}
|
||||||
candidates[details.rawFilter] = new RegExp(reStr + '(?:\\n|$)');
|
candidates[details.rawFilter] = new RegExp(reStr.join('\\v') + '(?:\\n|$)');
|
||||||
|
|
||||||
// Second step: find hostname-based versions.
|
// Second step: find hostname-based versions.
|
||||||
// Reference: FilterContainer.compileHostnameSelector().
|
// Reference: FilterContainer.compileHostnameSelector().
|
||||||
|
@ -135,9 +135,7 @@ var fromCosmeticFilter = function(details) {
|
||||||
if ( hostname !== '' ) {
|
if ( hostname !== '' ) {
|
||||||
for ( ;; ) {
|
for ( ;; ) {
|
||||||
candidates[hostname + '##' + filter] = new RegExp(
|
candidates[hostname + '##' + filter] = new RegExp(
|
||||||
reEscape('c\vh\v') +
|
['c', 'h', '\\w+', reEscape(hostname), reEscape(filter)].join('\\v') +
|
||||||
'\\w+' +
|
|
||||||
reEscape('\v' + hostname + '\v' + filter) +
|
|
||||||
'(?:\\n|$)'
|
'(?:\\n|$)'
|
||||||
);
|
);
|
||||||
// If there is no valid domain, there won't be any other
|
// If there is no valid domain, there won't be any other
|
||||||
|
@ -162,7 +160,7 @@ var fromCosmeticFilter = function(details) {
|
||||||
if ( pos !== -1 ) {
|
if ( pos !== -1 ) {
|
||||||
var entity = domain.slice(0, pos);
|
var entity = domain.slice(0, pos);
|
||||||
candidates[entity + '.*##' + filter] = new RegExp(
|
candidates[entity + '.*##' + filter] = new RegExp(
|
||||||
reEscape('c\ve\v' + entity + '\v' + filter) +
|
['c', 'e', reEscape(entity), reEscape(filter)].join('\\v') +
|
||||||
'(?:\\n|$)'
|
'(?:\\n|$)'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue