mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-11 17:41:03 +01:00
Fix handling of backslashes in string expressions for :has-text()
This commit is contained in:
parent
a594b3f3d1
commit
60858b6719
1 changed files with 8 additions and 4 deletions
|
@ -173,14 +173,17 @@
|
||||||
')\\('
|
')\\('
|
||||||
].join(''));
|
].join(''));
|
||||||
|
|
||||||
const reEscapeRegex = /[.*+?^${}()|[\]\\]/g,
|
const reEatBackslashes = /\\([()])/g;
|
||||||
reNeedScope = /^\s*[+>~]/,
|
const reEscapeRegex = /[.*+?^${}()|[\]\\]/g;
|
||||||
reIsDanglingSelector = /(?:[+>~]\s*|\s+)$/;
|
const reNeedScope = /^\s*[+>~]/;
|
||||||
|
const reIsDanglingSelector = /(?:[+>~]\s*|\s+)$/;
|
||||||
|
|
||||||
const regexToRawValue = new Map();
|
const regexToRawValue = new Map();
|
||||||
let lastProceduralSelector = '',
|
let lastProceduralSelector = '',
|
||||||
lastProceduralSelectorCompiled;
|
lastProceduralSelectorCompiled;
|
||||||
|
|
||||||
|
// When dealing with literal text, we must first eat _some_
|
||||||
|
// backslash characters.
|
||||||
const compileText = function(s) {
|
const compileText = function(s) {
|
||||||
const match = reParseRegexLiteral.exec(s);
|
const match = reParseRegexLiteral.exec(s);
|
||||||
let regexDetails;
|
let regexDetails;
|
||||||
|
@ -191,7 +194,8 @@
|
||||||
regexDetails = [ regexDetails, match[2] ];
|
regexDetails = [ regexDetails, match[2] ];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
regexDetails = s.replace(reEscapeRegex, '\\$&');
|
regexDetails = s.replace(reEatBackslashes, '$1')
|
||||||
|
.replace(reEscapeRegex, '\\$&');
|
||||||
regexToRawValue.set(regexDetails, s);
|
regexToRawValue.set(regexDetails, s);
|
||||||
}
|
}
|
||||||
return regexDetails;
|
return regexDetails;
|
||||||
|
|
Loading…
Reference in a new issue