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);
|
return Reflect.has(resolved, p);
|
||||||
},
|
},
|
||||||
get(target, p, receiver) {
|
get(target, p, receiver) {
|
||||||
|
if (__DEV__ && p === "__IS_BUNNY_LAZY_PROXY__") return true;
|
||||||
|
|
||||||
const contextHolder = proxyContextHolder.get(target);
|
const contextHolder = proxyContextHolder.get(target);
|
||||||
|
|
||||||
if (contextHolder?.options) {
|
if (contextHolder?.options) {
|
||||||
|
|
@ -62,12 +64,12 @@ const lazyHandler: ProxyHandler<any> = {
|
||||||
return cacheKeys;
|
return cacheKeys;
|
||||||
},
|
},
|
||||||
getOwnPropertyDescriptor: (target, p) => {
|
getOwnPropertyDescriptor: (target, p) => {
|
||||||
|
if (isUnconfigurable(p)) return Reflect.getOwnPropertyDescriptor(target, p);
|
||||||
|
|
||||||
const contextHolder = proxyContextHolder.get(target);
|
const contextHolder = proxyContextHolder.get(target);
|
||||||
const resolved = contextHolder?.factory();
|
const resolved = contextHolder?.factory();
|
||||||
if (!resolved) throw new Error(`Trying to getOwnPropertyDescriptor of ${typeof resolved}`);
|
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);
|
const descriptor = Reflect.getOwnPropertyDescriptor(resolved, p);
|
||||||
if (descriptor) Object.defineProperty(target, p, descriptor);
|
if (descriptor) Object.defineProperty(target, p, descriptor);
|
||||||
return descriptor;
|
return descriptor;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { debounce } from "es-toolkit";
|
||||||
|
|
||||||
import { ModuleFlags, ModulesMapInternal } from "./enums";
|
import { ModuleFlags, ModulesMapInternal } from "./enums";
|
||||||
|
|
||||||
const CACHE_VERSION = 100;
|
const CACHE_VERSION = 102;
|
||||||
const BUNNY_METRO_CACHE_PATH = "caches/metro_modules.json";
|
const BUNNY_METRO_CACHE_PATH = "caches/metro_modules.json";
|
||||||
|
|
||||||
type ModulesMap = {
|
type ModulesMap = {
|
||||||
|
|
@ -13,7 +13,7 @@ type ModulesMap = {
|
||||||
|
|
||||||
let _metroCache = null as unknown as ReturnType<typeof buildInitCache>;
|
let _metroCache = null as unknown as ReturnType<typeof buildInitCache>;
|
||||||
|
|
||||||
export const getMetroCache = window.__getMetroCache = () => _metroCache;
|
export const getMetroCache = () => _metroCache;
|
||||||
|
|
||||||
function buildInitCache() {
|
function buildInitCache() {
|
||||||
const cache = {
|
const cache = {
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,8 @@ function isBadExports(exports: any) {
|
||||||
return !exports
|
return !exports
|
||||||
|| exports === window
|
|| exports === window
|
||||||
|| exports["<!@ pylix was here :fuyusquish: !@>"] === null
|
|| 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) {
|
function onModuleRequire(moduleExports: any, id: Metro.ModuleID) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue