From e12cd232a062d1e204ffa75e35ed0b509d92a465 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 3 Oct 2022 10:47:29 -0400 Subject: [PATCH] Procedural operators without parenthesis are invalid Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2305 Bump up selfie/compile version numbers. Related feedback: - https://github.com/gorhill/uBlock/commit/85adde9f0c67f9f3b37c6da2933bec4d4e296851#commitcomment-85569639 --- src/js/background.js | 4 ++-- src/js/static-filtering-parser.js | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/js/background.js b/src/js/background.js index e53bb5a40..4ac91efc3 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -175,8 +175,8 @@ const µBlock = { // jshint ignore:line // Read-only systemSettings: { - compiledMagic: 46, // Increase when compiled format changes - selfieMagic: 46, // Increase when selfie format changes + compiledMagic: 47, // Increase when compiled format changes + selfieMagic: 47, // Increase when selfie format changes }, // https://github.com/uBlockOrigin/uBlock-issues/issues/759#issuecomment-546654501 diff --git a/src/js/static-filtering-parser.js b/src/js/static-filtering-parser.js index 8219b914c..e0fc68ea8 100644 --- a/src/js/static-filtering-parser.js +++ b/src/js/static-filtering-parser.js @@ -1657,8 +1657,10 @@ Parser.prototype.SelectorCompiler = class { case 'Selector': if ( out.length !== 0 ) { out.push(','); } break; - default: + case 'SelectorList': break; + default: + return; } } return out.join(''); @@ -1697,11 +1699,6 @@ Parser.prototype.SelectorCompiler = class { case 'TypeSelector': prelude.push(this.astSerializePart(part)); break; - case 'Selector': - if ( prelude.length !== 0 ) { - prelude.push(', '); - } - break; case 'ProceduralSelector': if ( prelude.length !== 0 ) { if ( tasks.length === 0 ) { @@ -1715,8 +1712,15 @@ Parser.prototype.SelectorCompiler = class { if ( args === undefined ) { return; } tasks.push([ data.name, args ]); break; - default: + case 'Selector': + if ( prelude.length !== 0 ) { + prelude.push(', '); + } break; + case 'SelectorList': + break; + default: + return; } } if ( tasks.length === 0 && out.action === undefined ) { @@ -1796,6 +1800,7 @@ Parser.prototype.SelectorCompiler = class { if ( Array.isArray(parts) && parts.length !== 0 ) { arg = this.astSerialize(parts); } + if ( arg === undefined ) { return; } switch ( operator ) { case 'has-text': return this.compileText(arg);