mirror of https://github.com/gorhill/uBlock.git
Classify generic cosmetic filters with comma as highly generic
Related discussion: https://old.reddit.com/r/uBlockOrigin/comments/1d3ezoy/
This commit is contained in:
parent
82a3992896
commit
8f81833efc
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue