fix(metro): Blacklist IntlMessagesProxy exports
Blacklist an evil module that always returns a function.
More info: 7f721c2bdb
This commit is contained in:
parent
821cbf01f2
commit
e2a05a77ee
3 changed files with 8 additions and 5 deletions
|
|
@ -41,6 +41,8 @@ const lazyHandler: ProxyHandler<any> = {
|
|||
return Reflect.has(resolved, p);
|
||||
},
|
||||
get(target, p, receiver) {
|
||||
if (__DEV__ && p === "__IS_BUNNY_LAZY_PROXY__") return true;
|
||||
|
||||
const contextHolder = proxyContextHolder.get(target);
|
||||
|
||||
if (contextHolder?.options) {
|
||||
|
|
@ -62,12 +64,12 @@ const lazyHandler: ProxyHandler<any> = {
|
|||
return cacheKeys;
|
||||
},
|
||||
getOwnPropertyDescriptor: (target, p) => {
|
||||
if (isUnconfigurable(p)) return Reflect.getOwnPropertyDescriptor(target, p);
|
||||
|
||||
const contextHolder = proxyContextHolder.get(target);
|
||||
const resolved = contextHolder?.factory();
|
||||
if (!resolved) throw new Error(`Trying to getOwnPropertyDescriptor of ${typeof resolved}`);
|
||||
|
||||
if (isUnconfigurable(p)) return Reflect.getOwnPropertyDescriptor(target, p);
|
||||
|
||||
const descriptor = Reflect.getOwnPropertyDescriptor(resolved, p);
|
||||
if (descriptor) Object.defineProperty(target, p, descriptor);
|
||||
return descriptor;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { debounce } from "es-toolkit";
|
|||
|
||||
import { ModuleFlags, ModulesMapInternal } from "./enums";
|
||||
|
||||
const CACHE_VERSION = 100;
|
||||
const CACHE_VERSION = 102;
|
||||
const BUNNY_METRO_CACHE_PATH = "caches/metro_modules.json";
|
||||
|
||||
type ModulesMap = {
|
||||
|
|
@ -13,7 +13,7 @@ type ModulesMap = {
|
|||
|
||||
let _metroCache = null as unknown as ReturnType<typeof buildInitCache>;
|
||||
|
||||
export const getMetroCache = window.__getMetroCache = () => _metroCache;
|
||||
export const getMetroCache = () => _metroCache;
|
||||
|
||||
function buildInitCache() {
|
||||
const cache = {
|
||||
|
|
|
|||
|
|
@ -76,7 +76,8 @@ function isBadExports(exports: any) {
|
|||
return !exports
|
||||
|| exports === window
|
||||
|| exports["<!@ pylix was here :fuyusquish: !@>"] === null
|
||||
|| (exports.__proto__ === Object.prototype && Reflect.ownKeys(exports).length === 0);
|
||||
|| (exports.__proto__ === Object.prototype && Reflect.ownKeys(exports).length === 0)
|
||||
|| (exports.default?.[Symbol.toStringTag] === "IntlMessagesProxy");
|
||||
}
|
||||
|
||||
function onModuleRequire(moduleExports: any, id: Metro.ModuleID) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue