From 647431d9f1ee1210acf3d6718564d6ed88e9b7b5 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 15 Apr 2022 11:06:29 -0400 Subject: [PATCH] Log excepted scriptlets unconditionally Regression from: - https://github.com/gorhill/uBlock/commit/efe2e0c78a25e71eea616035384c185c453378c0 --- src/js/scriptlet-filtering.js | 44 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/js/scriptlet-filtering.js b/src/js/scriptlet-filtering.js index ebeea7e9b..1e6c3b12d 100644 --- a/src/js/scriptlet-filtering.js +++ b/src/js/scriptlet-filtering.js @@ -222,6 +222,18 @@ const patchScriptlet = function(content, args) { return content; }; +const logOne = function(tabId, url, filter) { + µb.filteringContext + .duplicate() + .fromTabId(tabId) + .setRealm('extended') + .setType('dom') + .setURL(url) + .setDocOriginFromURL(url) + .setFilter({ source: 'extended', raw: filter }) + .toLogger(); +}; + scriptletFilteringEngine.reset = function() { scriptletDB.clear(); duplicates.clear(); @@ -332,15 +344,12 @@ scriptletFilteringEngine.retrieve = function(request, options = {}) { return; } + const mustLog = Array.isArray(options.logEntries); + // Wholly disable scriptlet injection? if ( $exceptions.has('') ) { - if ( Array.isArray(options.logEntries) ) { - options.logEntries.push({ - isException: true, - token: '', - tabId: request.tabId, - url: request.url, - }); + if ( mustLog ) { + logOne(request.tabId, request.url, '#@#+js()'); } return; } @@ -358,10 +367,12 @@ scriptletFilteringEngine.retrieve = function(request, options = {}) { if ( isException === false ) { out.push(code); } - if ( Array.isArray(options.logEntries) ) { + if ( mustLog === false ) { continue; } + if ( isException ) { + logOne(request.tabId, request.url, `#@#+js(${token})`); + } else { options.logEntries.push({ - isException, - token, + token: `##+js(${token})`, tabId: request.tabId, url: request.url, }); @@ -424,18 +435,7 @@ scriptletFilteringEngine.injectNow = function(details) { promise.then(results => { if ( Array.isArray(results) === false || results[0] !== 0 ) { return; } for ( const entry of logEntries ) { - µb.filteringContext - .duplicate() - .fromTabId(entry.tabId) - .setRealm('extended') - .setType('dom') - .setURL(entry.url) - .setDocOriginFromURL(entry.url) - .setFilter({ - source: 'extended', - raw: (entry.isException ? '#@#' : '##') + `+js(${entry.token})` - }) - .toLogger(); + logOne(entry.tabId, entry.url, entry.token); } }); };