From c3f267db8fe1c3a7ed98662a31ddb7172a166e10 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 8 Oct 2020 09:49:35 -0400 Subject: [PATCH] Improve bad filter detection in element picker Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/1280 --- src/js/epicker-ui.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/js/epicker-ui.js b/src/js/epicker-ui.js index 2242ec538..15eefafe0 100644 --- a/src/js/epicker-ui.js +++ b/src/js/epicker-ui.js @@ -71,9 +71,17 @@ const filterFromTextarea = function() { if ( s === '' ) { return ''; } const pos = s.indexOf('\n'); const filter = pos === -1 ? s.trim() : s.slice(0, pos).trim(); - staticFilteringParser.analyze(filter); - staticFilteringParser.analyzeExtra(); - return staticFilteringParser.shouldDiscard() ? '!' : filter; + const sfp = staticFilteringParser; + sfp.analyze(filter); + sfp.analyzeExtra(); + if ( + sfp.category !== sfp.CATStaticExtFilter && + sfp.category !== sfp.CATStaticNetFilter || + sfp.shouldDiscard() + ) { + return '!'; + } + return filter; }; /******************************************************************************/