1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-05 18:32:30 +01:00

Fix handling of backslashes in string expressions for :has-text()

This commit is contained in:
Raymond Hill 2019-04-15 18:56:28 -04:00
parent a594b3f3d1
commit 60858b6719
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -173,14 +173,17 @@
')\\('
].join(''));
const reEscapeRegex = /[.*+?^${}()|[\]\\]/g,
reNeedScope = /^\s*[+>~]/,
reIsDanglingSelector = /(?:[+>~]\s*|\s+)$/;
const reEatBackslashes = /\\([()])/g;
const reEscapeRegex = /[.*+?^${}()|[\]\\]/g;
const reNeedScope = /^\s*[+>~]/;
const reIsDanglingSelector = /(?:[+>~]\s*|\s+)$/;
const regexToRawValue = new Map();
let lastProceduralSelector = '',
lastProceduralSelectorCompiled;
// When dealing with literal text, we must first eat _some_
// backslash characters.
const compileText = function(s) {
const match = reParseRegexLiteral.exec(s);
let regexDetails;
@ -191,7 +194,8 @@
regexDetails = [ regexDetails, match[2] ];
}
} else {
regexDetails = s.replace(reEscapeRegex, '\\$&');
regexDetails = s.replace(reEatBackslashes, '$1')
.replace(reEscapeRegex, '\\$&');
regexToRawValue.set(regexDetails, s);
}
return regexDetails;