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
|
Home: https://github.com/gorhill/uBlock
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
import logger from './logger.js';
|
|
||||||
import µb from './background.js';
|
|
||||||
|
|
||||||
import { MRUCache } from './mrucache.js';
|
import { MRUCache } from './mrucache.js';
|
||||||
import { StaticExtFilteringHostnameDB } from './static-ext-filtering-db.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.
|
// It's an uncommon case, so it's best to unescape only when needed.
|
||||||
|
|
||||||
const keyFromSelector = selector => {
|
const keyFromSelector = selector => {
|
||||||
|
let matches = reSimplestSelector.exec(selector);
|
||||||
|
if ( matches !== null ) { return matches[0]; }
|
||||||
let key = '';
|
let key = '';
|
||||||
let matches = rePlainSelector.exec(selector);
|
matches = rePlainSelector.exec(selector);
|
||||||
if ( matches !== null ) {
|
if ( matches !== null ) {
|
||||||
key = matches[0];
|
key = matches[0];
|
||||||
} else {
|
} else {
|
||||||
|
@ -176,6 +175,7 @@ const keyFromSelector = selector => {
|
||||||
if ( matches === null ) { return; }
|
if ( matches === null ) { return; }
|
||||||
key = matches[1] || matches[2];
|
key = matches[1] || matches[2];
|
||||||
}
|
}
|
||||||
|
if ( selector.includes(',') ) { return; }
|
||||||
if ( key.includes('\\') === false ) { return key; }
|
if ( key.includes('\\') === false ) { return key; }
|
||||||
matches = rePlainSelectorEscaped.exec(selector);
|
matches = rePlainSelectorEscaped.exec(selector);
|
||||||
if ( matches === null ) { return; }
|
if ( matches === null ) { return; }
|
||||||
|
@ -198,8 +198,9 @@ const keyFromSelector = selector => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const reSimplestSelector = /^[#.][\w-]+$/;
|
||||||
const rePlainSelector = /^[#.][\w\\-]+/;
|
const rePlainSelector = /^[#.][\w\\-]+/;
|
||||||
const rePlainSelectorEx = /^[^#.\[(]+([#.][\w-]+)|([#.][\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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue