mirror of
https://github.com/koush/scrypted.git
synced 2026-03-09 20:22:18 +00:00
server: use function constructor rather than eval
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user