1919 Home: https://github.com/gorhill/uBlock
2020*/
2121
22- 'use strict' ;
23-
2422/******************************************************************************/
2523
26- import logger from './logger.js' ;
27- import µb from './background.js' ;
28-
2924import { MRUCache } from './mrucache.js' ;
3025import { StaticExtFilteringHostnameDB } from './static-ext-filtering-db.js' ;
26+ import logger from './logger.js' ;
27+ import µb from './background.js' ;
3128
3229/******************************************************************************/
3330/******************************************************************************/
@@ -167,15 +164,18 @@ const hashFromStr = (type, s) => {
167164// It's an uncommon case, so it's best to unescape only when needed.
168165
169166const keyFromSelector = selector => {
167+ let matches = reSimplestSelector . exec ( selector ) ;
168+ if ( matches !== null ) { return matches [ 0 ] ; }
170169 let key = '' ;
171- let matches = rePlainSelector . exec ( selector ) ;
170+ matches = rePlainSelector . exec ( selector ) ;
172171 if ( matches !== null ) {
173172 key = matches [ 0 ] ;
174173 } else {
175174 matches = rePlainSelectorEx . exec ( selector ) ;
176175 if ( matches === null ) { return ; }
177176 key = matches [ 1 ] || matches [ 2 ] ;
178177 }
178+ if ( selector . includes ( ',' ) ) { return ; }
179179 if ( key . includes ( '\\' ) === false ) { return key ; }
180180 matches = rePlainSelectorEscaped . exec ( selector ) ;
181181 if ( matches === null ) { return ; }
@@ -198,8 +198,9 @@ const keyFromSelector = selector => {
198198 }
199199} ;
200200
201+ const reSimplestSelector = / ^ [ # . ] [ \w - ] + $ / ;
201202const rePlainSelector = / ^ [ # . ] [ \w \\ - ] + / ;
202- const rePlainSelectorEx = / ^ [ ^ # . \ [( ] + ( [ # . ] [ \w - ] + ) | ( [ # . ] [ \w - ] + ) $ / ;
203+ const rePlainSelectorEx = / ^ [ ^ # . [ ( ] + ( [ # . ] [ \w - ] + ) | ( [ # . ] [ \w - ] + ) $ / ;
203204const rePlainSelectorEscaped = / ^ [ # . ] (?: \\ [ 0 - 9 A - F a - f ] + | \\ .| \w | - ) + / ;
204205const reEscapeSequence = / \\ ( [ 0 - 9 A - F a - f ] + | .) / g;
205206
0 commit comments