From 890aabaae942315c9b06985723188ef8c3889821 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 8 Mar 2023 13:49:21 -0500 Subject: [PATCH] Make parser take into account `filterOnHeaders` setting Related feedback: - https://github.com/uBlockOrigin/uBlock-issues/issues/1134#issuecomment-1460638431 --- src/js/codemirror/ubo-static-filtering.js | 1 + src/js/messaging.js | 1 + src/js/static-filtering-parser.js | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/js/codemirror/ubo-static-filtering.js b/src/js/codemirror/ubo-static-filtering.js index 70027ae68..04e0abafa 100644 --- a/src/js/codemirror/ubo-static-filtering.js +++ b/src/js/codemirror/ubo-static-filtering.js @@ -288,6 +288,7 @@ CodeMirror.defineMode('ubo-static-filtering', function() { hintHelperRegistered = true; initHints(); } + astParser.options.filterOnHeaders = details.filterOnHeaders === true; }, parser: astParser, }; diff --git a/src/js/messaging.js b/src/js/messaging.js index 39d381ae7..958bf62f6 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -1519,6 +1519,7 @@ const onMessage = function(request, sender, callback) { response.preparseDirectiveHints = sfp.utils.preparser.getHints(); response.expertMode = µb.hiddenSettings.filterAuthorMode; + response.filterOnHeaders = µb.hiddenSettings.filterOnHeaders; } if ( request.hintUpdateToken !== µb.pageStoresToken ) { response.originHints = getOriginHints(); diff --git a/src/js/static-filtering-parser.js b/src/js/static-filtering-parser.js index 181dfc7cf..0b328328f 100644 --- a/src/js/static-filtering-parser.js +++ b/src/js/static-filtering-parser.js @@ -1221,7 +1221,7 @@ export class AstFilterParser { realBad = isException === false || isNegated || hasValue; break; case NODE_TYPE_NET_OPTION_NAME_HEADER: - realBad = this.expertMode === false || isNegated || hasValue === false; + realBad = this.options.filterOnHeaders !== true || isNegated || hasValue === false; break; case NODE_TYPE_NET_OPTION_NAME_IMPORTANT: realBad = isException || isNegated || hasValue;