From 07d3c96261656e44f674550fbde50da8f6a15acc Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 26 May 2021 07:22:17 -0400 Subject: [PATCH] Fix potential exception when casting to string Related discussion: - https://github.com/uBlockOrigin/uAssets/issues/9123#issuecomment-848255120 --- assets/resources/scriptlets.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/assets/resources/scriptlets.js b/assets/resources/scriptlets.js index 69c327a7b..591763412 100644 --- a/assets/resources/scriptlets.js +++ b/assets/resources/scriptlets.js @@ -307,6 +307,7 @@ /// addEventListener-defuser.js /// alias aeld.js +// https://github.com/uBlockOrigin/uAssets/issues/9123#issuecomment-848255120 (function() { let needle1 = '{{1}}'; if ( needle1 === '' || needle1 === '{{1}}' ) { @@ -330,8 +331,12 @@ self.EventTarget.prototype.addEventListener, { apply: function(target, thisArg, args) { - const type = String(args[0]); - const handler = String(args[1]); + let type, handler; + try { + type = String(args[0]); + handler = String(args[1]); + } catch(ex) { + } if ( needle1.test(type) === false || needle2.test(handler) === false @@ -346,14 +351,19 @@ /// addEventListener-logger.js /// alias aell.js +// https://github.com/uBlockOrigin/uAssets/issues/9123#issuecomment-848255120 (function() { const log = console.log.bind(console); self.EventTarget.prototype.addEventListener = new Proxy( self.EventTarget.prototype.addEventListener, { apply: function(target, thisArg, args) { - const type = String(args[0]); - const handler = String(args[1]); + let type, handler; + try { + type = String(args[0]); + handler = String(args[1]); + } catch(ex) { + } log('uBO: addEventListener("%s", %s)', type, handler); return target.apply(thisArg, args); }