From 97d6d5028b948a6d4e0cbf40cdb21486f64d39b1 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 12 Sep 2019 13:05:41 -0400 Subject: [PATCH] Fix mishandling of procedural cosmetic exceptions in logger Issue reported by @uBlock-user in team channel. Creating cosmetic procedural exception filters was causing `cosmetic-logger.js` scriptlet to throw at and thus further breaking the logging of cosmetic filters overall. --- src/js/scriptlets/cosmetic-logger.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/js/scriptlets/cosmetic-logger.js b/src/js/scriptlets/cosmetic-logger.js index f58180a0c..6be34fb5b 100644 --- a/src/js/scriptlets/cosmetic-logger.js +++ b/src/js/scriptlets/cosmetic-logger.js @@ -254,12 +254,18 @@ const handlers = { if ( Array.isArray(changes.exceptions) ) { for ( const selector of changes.exceptions ) { if ( loggedSelectors.has(selector) ) { continue; } - if ( selector.charCodeAt(0) === 0x7B /* '{' */ ) { - const details = JSON.parse(selector); - exceptionDict.set(details.style[0], details.raw); - } else { + if ( selector.charCodeAt(0) !== 0x7B /* '{' */ ) { exceptionDict.set(selector, selector); + continue; } + const details = JSON.parse(selector); + if ( Array.isArray(details.style) ) { + exceptionDict.set(details.style[0], details.raw); + continue; + } + // TODO: + // Handling of procedural cosmetic exception filters + // not implemented. } exceptionStr = undefined; }