1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-03 09:39:38 +02:00

[mv3] Properly compiled complex generic cosmetic filters

Related issue:
- https://github.com/uBlockOrigin/uBOL-issues/issues/47
This commit is contained in:
Raymond Hill 2023-06-14 10:19:48 -04:00
parent a2b51a8f91
commit d590390431
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -53,16 +53,21 @@ const hashFromStr = (type, s) => {
// dependencies
const rePlainSelector = /^[#.][\w\\-]+/;
const rePlainSelectorEx = /^[^#.\[(]+([#.][\w-]+)|([#.][\w-]+)$/;
const rePlainSelectorEscaped = /^[#.](?:\\[0-9A-Fa-f]+ |\\.|\w|-)+/;
const reEscapeSequence = /\\([0-9A-Fa-f]+ |.)/g;
const keyFromSelector = selector => {
let key = '';
let matches = rePlainSelector.exec(selector);
if ( matches === null ) { return; }
let key = matches[0];
if ( key.indexOf('\\') === -1 ) {
return key;
if ( matches ) {
key = matches[0];
} else {
matches = rePlainSelectorEx.exec(selector);
if ( matches === null ) { return; }
key = matches[1] || matches[2];
}
if ( key.indexOf('\\') === -1 ) { return key; }
matches = rePlainSelectorEscaped.exec(selector);
if ( matches === null ) { return; }
key = '';