1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 03:12:33 +01: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 // dependencies
const rePlainSelector = /^[#.][\w\\-]+/; const rePlainSelector = /^[#.][\w\\-]+/;
const rePlainSelectorEx = /^[^#.\[(]+([#.][\w-]+)|([#.][\w-]+)$/;
const rePlainSelectorEscaped = /^[#.](?:\\[0-9A-Fa-f]+ |\\.|\w|-)+/; const rePlainSelectorEscaped = /^[#.](?:\\[0-9A-Fa-f]+ |\\.|\w|-)+/;
const reEscapeSequence = /\\([0-9A-Fa-f]+ |.)/g; const reEscapeSequence = /\\([0-9A-Fa-f]+ |.)/g;
const keyFromSelector = selector => { const keyFromSelector = selector => {
let key = '';
let matches = rePlainSelector.exec(selector); let matches = rePlainSelector.exec(selector);
if ( matches ) {
key = matches[0];
} else {
matches = rePlainSelectorEx.exec(selector);
if ( matches === null ) { return; } if ( matches === null ) { return; }
let key = matches[0]; key = matches[1] || matches[2];
if ( key.indexOf('\\') === -1 ) {
return key;
} }
if ( key.indexOf('\\') === -1 ) { return key; }
matches = rePlainSelectorEscaped.exec(selector); matches = rePlainSelectorEscaped.exec(selector);
if ( matches === null ) { return; } if ( matches === null ) { return; }
key = ''; key = '';