From 034c915f3be1257ed5de638a456e7c95932c553d Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 24 Feb 2020 13:40:17 -0500 Subject: [PATCH] Allow re-entrance in abort-current-inline-script Related feedback: - https://github.com/DandelionSprout/adfilt/issues/7#issuecomment-590391877 If a property is already trapped with a getter/setter, propagate to these after validation succeed. --- assets/resources/scriptlets.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/assets/resources/scriptlets.js b/assets/resources/scriptlets.js index a8e03a261..3d6f5a205 100644 --- a/assets/resources/scriptlets.js +++ b/assets/resources/scriptlets.js @@ -56,12 +56,13 @@ if ( owner instanceof Object === false ) { return; } } let value; - const desc = Object.getOwnPropertyDescriptor(owner, prop); + let desc = Object.getOwnPropertyDescriptor(owner, prop); if ( desc instanceof Object === false || desc.get instanceof Function === false ) { value = owner[prop]; + desc = undefined; } const magic = String.fromCharCode(Date.now() % 26 + 97) + Math.floor(Math.random() * 982451653 + 982451653).toString(36); @@ -79,11 +80,17 @@ Object.defineProperty(owner, prop, { get: function() { validate(); - return value; + return desc instanceof Object + ? desc.get() + : value; }, set: function(a) { validate(); - value = a; + if ( desc instanceof Object ) { + desc.set(a); + } else { + value = a; + } } }); const oe = window.onerror;