SandboxJS icon indicating copy to clipboard operation
SandboxJS copied to clipboard

Error: `arguments` is undefined

Open daniele-pini opened this issue 3 years ago • 1 comments

This code doesn't currently work in SandboxJS (you can try it quick on the dev tools in https://nyariv.github.io/SandboxJS/):

const sandbox = new Sandbox();

const code = `
  function test() {
    console.log(arguments); // Uncaught ReferenceError: arguments is not defined
  }

  test(1, 2, 3);
`;

const exec = sandbox.compile(code);
exec(scope).run();

However in normal JS the content code should work:

function test() {
  console.log(arguments); // OK, prints an Arguments object
}

test(1, 2, 3);

daniele-pini avatar Nov 28 '22 12:11 daniele-pini

This is not supported by design, because it could be used to pollute a scope wrapping a piece of untrusted code.

nyariv avatar Dec 03 '22 16:12 nyariv