mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 09:07:54 +01:00
fix #2666
This commit is contained in:
parent
4a36bf814b
commit
dbe95c438b
1 changed files with 13 additions and 13 deletions
|
@ -30,14 +30,6 @@ var listEntries = Object.create(null),
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
// Helpers
|
||||
|
||||
var reEscape = function(s) {
|
||||
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
var fromNetFilter = function(details) {
|
||||
var lists = [],
|
||||
compiledFilter = details.compiledFilter,
|
||||
|
@ -108,11 +100,10 @@ var fromCosmeticFilter = function(details) {
|
|||
prefix = match[0],
|
||||
filter = details.rawFilter.slice(prefix.length);
|
||||
|
||||
var compiled = JSON.stringify(filter).slice(1, -1),
|
||||
reFilter = new RegExp(
|
||||
'(?:^|\\n)[^\\n]*?("|\\")?' +
|
||||
reEscape(compiled) +
|
||||
'\\1[^\\n]*?(?:\\n|$)',
|
||||
var reFilter = new RegExp(
|
||||
'(?:^|\\n)[^\\n]*?\\\\*"' +
|
||||
reEscapeCosmetic(filter) +
|
||||
'\\\\*"[^\\n]*?(?:\\n|$)',
|
||||
'g'
|
||||
);
|
||||
|
||||
|
@ -204,6 +195,15 @@ var fromCosmeticFilter = function(details) {
|
|||
});
|
||||
};
|
||||
|
||||
// https://github.com/gorhill/uBlock/issues/2666
|
||||
// Raw filters in compiled filter lists may have been JSON-stringified one or
|
||||
// multiple times.
|
||||
|
||||
var reEscapeCosmetic = function(s) {
|
||||
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||
.replace(/"/g, '\\\\*"');
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
onmessage = function(e) { // jshint ignore:line
|
||||
|
|
Loading…
Reference in a new issue