Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 404 and 406. #407

Merged
merged 2 commits into from Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@
v3.9.8 (TBD)
-------------------
[fix] Add function typecheck for arguments, caller, and callee property check (GeoffRen)
[fix] Fix find best extension handler

v3.9.7 (2022-02-10)
-------------------
[fix] Allow relative require from base script
Expand Down
4 changes: 3 additions & 1 deletion lib/bridge.js
Expand Up @@ -431,7 +431,9 @@ function createBridge(otherInit, registerProxy) {
case 'arguments':
case 'caller':
case 'callee':
if (thisOtherHasOwnProperty(object, key)) throw thisThrowCallerCalleeArgumentsAccess(key);
if (typeof object === 'function' && thisOtherHasOwnProperty(object, key)) {
throw thisThrowCallerCalleeArgumentsAccess(key);
}
break;
}
let ret; // @other(unsafe)
Expand Down
4 changes: 2 additions & 2 deletions lib/nodevm.js
Expand Up @@ -405,9 +405,9 @@ class NodeVM extends VM {
}
}
const prefix = strict ? STRICT_MODULE_PREFIX : MODULE_PREFIX;
let scriptCode = prefix + this._compiler(code, unresolvedFilename) + MODULE_SUFFIX;
let scriptCode = this._compiler(code, unresolvedFilename);
scriptCode = transformer(null, scriptCode, false, false).code;
script = new Script(scriptCode, {
script = new Script(prefix + scriptCode + MODULE_SUFFIX, {
__proto__: null,
filename: unresolvedFilename,
displayErrors: false
Expand Down
2 changes: 1 addition & 1 deletion lib/setup-node-sandbox.js
Expand Up @@ -148,7 +148,7 @@ Module._cache = {__proto__: null};
function findBestExtensionHandler(filename) {
const name = resolver.pathBasename(filename);
for (let i = 0; (i = localStringPrototypeIndexOf(name, '.', i + 1)) !== -1;) {
const ext = localStringPrototypeSlice(name, i + 1);
const ext = localStringPrototypeSlice(name, i);
const handler = Module._extensions[ext];
if (handler) return handler;
}
Expand Down
3 changes: 2 additions & 1 deletion test/nodevm.js
Expand Up @@ -77,7 +77,8 @@ describe('modules', () => {
it('require json', () => {
const vm = new NodeVM({
require: {
external: true
external: true,
context: 'sandbox'
}
});

Expand Down
4 changes: 4 additions & 0 deletions test/vm.js
Expand Up @@ -380,6 +380,10 @@ describe('contextify', () => {
}
});

it('arguments', () => {
assert.doesNotThrow(() => vm.run('(o) => o.arguments')({arguments: 1}));
});

after(() => {
vm = null;
});
Expand Down