Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Cyclic references in values returned from a native callback are now detected and reported as an exception, instead of crashing the VM with a stack overflow.
- Native callbacks now honor `toJSON()` on returned values; values that are not serializable (functions, symbols) are omitted from objects or serialized as `null` in arrays, consistent with `JSON.stringify` semantics.
- Fix: `evaluateSnippetMulti` and `evaluateFileMulti` now correctly preserve a file key named `__proto__` in the returned object (no security impact: the key was silently dropped rather than causing prototype pollution).

## v3.3.1 (2026-05-24)

Expand Down
8 changes: 8 additions & 0 deletions spec/binding_spec.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,14 @@ describe('binding', () => {
});
});

it('preserves __proto__ key in multi output', async () => {
const jsonnet = new Jsonnet();

const dict = await jsonnet.evaluateSnippetMulti(`{"__proto__": {v: 1}}`);
expect(Object.hasOwn(dict, '__proto__')).toBeTrue();
expect(dict['__proto__']).toBe('{\n "v": 1\n}\n');
});

it('reports error for evaluateSnippetMulti', async () => {
const jsonnet = new Jsonnet();

Expand Down
1 change: 1 addition & 0 deletions src/JsonnetWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ namespace nodejsonnet {
namespace {
Napi::Value parseMultiValue(Napi::Env env, JsonnetVm::Buffer buffer) {
auto result = Napi::Object::New(env);
result.Set("__proto__", env.Null()); // TODO: Use node_api_set_prototype when stabilized.

for(auto p = buffer.get(); *p;) {
std::string_view const name(p);
Expand Down
Loading