Skip to content

Commit

Permalink
server: use function constructor rather than eval
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Aug 4, 2024
1 parent bd60e39 commit 4ed6d1a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions server/src/rpc-peer-eval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ function compileFunction(code: string, params?: ReadonlyArray<string>, options?:
params = params || [];
if (options?.filename)
code = `${code}\n//# sourceURL=${options.filename}\n`;
const f = `(function(${params.join(',')}) {;${code}\n;})`;
return eval(f);
return new Function(...params, code);
}

export function evalLocal<T>(peer: RpcPeer, script: string, filename?: string, coercedParams?: { [name: string]: any }): T {
Expand Down

0 comments on commit 4ed6d1a

Please sign in to comment.