Explorar o código

fix: safeguard more stuff, #1400

* EventTarget
* "s" in WebPack bootstrap
tophf %!s(int64=3) %!d(string=hai) anos
pai
achega
b74c9d3a4c

+ 1 - 1
scripts/webpack-protect-bootstrap-plugin.js

@@ -17,7 +17,7 @@ class WebpackProtectBootstrapPlugin {
       hooks.localVars.tap(NAME, src => replace(src, [[
         'installedModules = {};',
         `installedModules = ${NULL_OBJ}; \
-         for (let i = 0, c, str = "cdmnoprt"; i < str.length && (c = str[i++]);) \
+         for (let i = 0, c, str = "cdmnoprst"; i < str.length && (c = str[i++]);) \
            defineProperty(${requireFn}, c, { ${NULL_PROTO}, value: undefined, writable: true });`,
       ]]));
       hooks.moduleObj.tap(NAME, src => replace(src, [[

+ 1 - 1
src/injected/web/gm-global-wrapper.js

@@ -148,7 +148,7 @@ for (const name in unforgeables) { /* proto is null */// eslint-disable-line gua
     delete unforgeables[name];
   }
 }
-[EventTarget, Object]::forEach(src => {
+[EventTargetSafe, Object]::forEach(src => {
   getOwnPropertyNames(src[PROTO])::forEach(key => {
     inheritedKeys[key] = 1;
   });

+ 2 - 0
src/injected/web/safe-globals-web.js

@@ -12,6 +12,7 @@ export let
   CustomEventSafe,
   DOMParserSafe,
   ErrorSafe,
+  EventTargetSafe,
   FileReaderSafe,
   KeyboardEventSafe,
   MouseEventSafe,
@@ -104,6 +105,7 @@ export const VAULT = (() => {
     CustomEventSafe = res[i += 1] || src.CustomEvent,
     DOMParserSafe = res[i += 1] || src.DOMParser,
     ErrorSafe = res[i += 1] || src.Error,
+    EventTargetSafe = res[i += 1] || src.EventTarget,
     FileReaderSafe = res[i += 1] || src.FileReader,
     KeyboardEventSafe = res[i += 1] || src.KeyboardEvent,
     MouseEventSafe = res[i += 1] || src.MouseEvent,