Skip to content

Commit

Permalink
fix: eval执行脚本内方法
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Nov 22, 2021
1 parent dac2cc6 commit 4d0e056
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/pkg/sandbox/sandbox.ts
Expand Up @@ -42,7 +42,7 @@ for (const key in descs) {
export function buildThis(global: any, context: any) {
let special = Object.assign({}, writables);
// 后台脚本要不要考虑不能使用eval?
let _this: any = { eval: global.eval };
let _this: any = {};
let proxy: any = new Proxy(context, {
defineProperty(_, name, desc) {
return Object.defineProperty(context, name, desc);
Expand Down Expand Up @@ -113,5 +113,6 @@ export function buildThis(global: any, context: any) {
return ret;
}
});
_this.eval = global.eval.bind(proxy);
return proxy;
}

0 comments on commit 4d0e056

Please sign in to comment.