From 5244ad5bafd754d55726017d4fcbe317001e7ec7 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sun, 29 Oct 2023 10:22:54 -0400 Subject: [PATCH] Do not use `bind` as a way to access native calls --- assets/resources/scriptlets.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/assets/resources/scriptlets.js b/assets/resources/scriptlets.js index 68d896f49..a3083293f 100644 --- a/assets/resources/scriptlets.js +++ b/assets/resources/scriptlets.js @@ -60,8 +60,11 @@ function safeSelf() { 'addEventListener': self.EventTarget.prototype.addEventListener, 'removeEventListener': self.EventTarget.prototype.removeEventListener, 'fetch': self.fetch, - 'JSON_parse': self.JSON.parse.bind(self.JSON), - 'JSON_stringify': self.JSON.stringify.bind(self.JSON), + 'JSON': self.JSON, + 'JSON_parseFn': self.JSON.parse, + 'JSON_stringifyFn': self.JSON.stringify, + 'JSON_parse': (...args) => safe.JSON_parseFn.call(safe.JSON, ...args), + 'JSON_stringify': (...args) => safe.JSON_stringifyFn.call(safe.JSON, ...args), 'log': console.log.bind(console), uboLog(...args) { if ( scriptletGlobals.has('canDebug') === false ) { return; }