1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-05 03:30:26 +02:00

Classify generic cosmetic filters with comma as highly generic

Related discussion:
https://old.reddit.com/r/uBlockOrigin/comments/1d3ezoy/
This commit is contained in:
Raymond Hill 2024-06-01 10:46:18 -04:00
parent 82a3992896
commit 8f81833efc
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -19,15 +19,12 @@
Home: https://github.com/gorhill/uBlock
*/
'use strict';
/******************************************************************************/
import logger from './logger.js';
import µb from './background.js';
import { MRUCache } from './mrucache.js';
import { StaticExtFilteringHostnameDB } from './static-ext-filtering-db.js';
import logger from './logger.js';
import µb from './background.js';
/******************************************************************************/
/******************************************************************************/
@ -167,8 +164,10 @@ const hashFromStr = (type, s) => {
// It's an uncommon case, so it's best to unescape only when needed.
const keyFromSelector = selector => {
let matches = reSimplestSelector.exec(selector);
if ( matches !== null ) { return matches[0]; }
let key = '';
let matches = rePlainSelector.exec(selector);
matches = rePlainSelector.exec(selector);
if ( matches !== null ) {
key = matches[0];
} else {
@ -176,6 +175,7 @@ const keyFromSelector = selector => {
if ( matches === null ) { return; }
key = matches[1] || matches[2];
}
if ( selector.includes(',') ) { return; }
if ( key.includes('\\') === false ) { return key; }
matches = rePlainSelectorEscaped.exec(selector);
if ( matches === null ) { return; }
@ -198,8 +198,9 @@ const keyFromSelector = selector => {
}
};
const reSimplestSelector = /^[#.][\w-]+$/;
const rePlainSelector = /^[#.][\w\\-]+/;
const rePlainSelectorEx = /^[^#.\[(]+([#.][\w-]+)|([#.][\w-]+)$/;
const rePlainSelectorEx = /^[^#.[(]+([#.][\w-]+)|([#.][\w-]+)$/;
const rePlainSelectorEscaped = /^[#.](?:\\[0-9A-Fa-f]+ |\\.|\w|-)+/;
const reEscapeSequence = /\\([0-9A-Fa-f]+ |.)/g;