From bbf06ad9729d2c0bceabc785d558ea330018dafa Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 7 Dec 2022 14:15:01 -0500 Subject: [PATCH] Fix parsing of `:matches-attr` arguments Related feedback: - https://github.com/uBlockOrigin/uBlock-issues/issues/2329#issuecomment-1341349992 --- src/js/static-filtering-parser.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/js/static-filtering-parser.js b/src/js/static-filtering-parser.js index af3fec451..bfa729e04 100644 --- a/src/js/static-filtering-parser.js +++ b/src/js/static-filtering-parser.js @@ -1919,7 +1919,7 @@ Parser.prototype.SelectorCompiler = class { if ( i === end ) { break; } c = s.charCodeAt(i); if ( c !== 0x5C && c !== quote ) { - out.push('\\'); + out.push(0x5C); } } out.push(c); @@ -1939,15 +1939,18 @@ Parser.prototype.SelectorCompiler = class { attr = r.s; } else { attr = r.s.slice(0, pos); - value = r.s.slice(pos + 1); + value = r.s.slice(pos+1); } } else { attr = r.s; if ( s.charCodeAt(r.i) !== 0x3D ) { return; } - r = this.unquoteString(s.slice(r.i+1)); - value = r.s; + value = s.slice(r.i+1); } if ( attr === '' ) { return; } + if ( value.length !== 0 ) { + r = this.unquoteString(value); + value = r.s; + } return { attr, value }; }