Skip to content

Commit

Permalink
Add sandboxed context parameter preventEscape
Browse files Browse the repository at this point in the history
Default: false.
This will fix: metarhia/Example#58

PR-URL: #41
  • Loading branch information
tshemsedinov committed Nov 30, 2020
1 parent 92e3093 commit a51c2b8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ First metavm implementation with following features
- Loader script from file with timeout and error handling
- Add `use strict` if it's not found, fix line offset
- Contexts, use default empty and frozen, emulated or pass one
- Use `microtaskMode` https://github.com/nodejs/node/pull/34023

[unreleased]: https://github.com/metarhia/metavm/compare/v0.1.0...HEAD
[0.1.0]: https://github.com/metarhia/metavm/releases/tag/v0.1.0
4 changes: 2 additions & 2 deletions lib/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ const COMMON_CONTEXT = vm.createContext(
})
);

const createContext = (context) => {
const createContext = (context, preventEscape = false) => {
if (!context) return EMPTY_CONTEXT;
return vm.createContext(context, CONTEXT_OPTIONS);
return vm.createContext(context, preventEscape ? CONTEXT_OPTIONS : {});
};

class MetaScript {
Expand Down

0 comments on commit a51c2b8

Please sign in to comment.