Skip to content

Commit

Permalink
[mv3] Properly compiled complex generic cosmetic filters
Browse files Browse the repository at this point in the history
Related issue:
- uBlockOrigin/uBOL-home#47
  • Loading branch information
gorhill committed Jun 14, 2023
1 parent a2b51a8 commit d590390
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/js/static-dnr-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,21 @@ const hashFromStr = (type, s) => {
// dependencies

const rePlainSelector = /^[#.][\w\\-]+/;
const rePlainSelectorEx = /^[^#.\[(]+([#.][\w-]+)|([#.][\w-]+)$/;
const rePlainSelectorEscaped = /^[#.](?:\\[0-9A-Fa-f]+ |\\.|\w|-)+/;
const reEscapeSequence = /\\([0-9A-Fa-f]+ |.)/g;

const keyFromSelector = selector => {
let key = '';
let matches = rePlainSelector.exec(selector);
if ( matches === null ) { return; }
let key = matches[0];
if ( key.indexOf('\\') === -1 ) {
return key;
if ( matches ) {
key = matches[0];
} else {
matches = rePlainSelectorEx.exec(selector);
if ( matches === null ) { return; }
key = matches[1] || matches[2];
}
if ( key.indexOf('\\') === -1 ) { return key; }
matches = rePlainSelectorEscaped.exec(selector);
if ( matches === null ) { return; }
key = '';
Expand Down

0 comments on commit d590390

Please sign in to comment.