From 04119e9cdda8c1b2305cd4cceedc8e28be96bf07 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 17 Oct 2022 07:26:51 -0400 Subject: [PATCH] Properly handle unsupported `nth-child(an of selector) Related feedback: - https://github.com/uBlockOrigin/uBlock-issues/issues/2284#issuecomment-1280325910 --- src/js/static-filtering-parser.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/js/static-filtering-parser.js b/src/js/static-filtering-parser.js index 04b904444..b73035b40 100644 --- a/src/js/static-filtering-parser.js +++ b/src/js/static-filtering-parser.js @@ -1614,6 +1614,7 @@ Parser.prototype.SelectorCompiler = class { out.push(`#${data.name}`); break; case 'Nth': { + if ( data.selector !== null ) { return; } if ( data.nth.type === 'AnPlusB' ) { const a = parseInt(data.nth.a, 10) || null; const b = parseInt(data.nth.b, 10) || null; @@ -1637,7 +1638,9 @@ Parser.prototype.SelectorCompiler = class { case 'PseudoElementSelector': out.push(`:${data.name}`); if ( Array.isArray(part.args) ) { - out.push(`(${this.astSerialize(part.args)})`); + const arg = this.astSerialize(part.args); + if ( typeof arg !== 'string' ) { return; } + out.push(`(${arg})`); } break; case 'Raw':