Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit a9a252f

Browse files
TooTallNatery
authored andcommitted
Read up the prototype of the 'env' object.
Closes GH-713.
1 parent 8a50f23 commit a9a252f

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

lib/child_process.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ ChildProcess.prototype.spawn = function(path, args, options, customFds) {
215215

216216
var envPairs = [];
217217
var keys = Object.keys(env);
218-
for (var index = 0, keysLength = keys.length; index < keysLength; index++) {
219-
var key = keys[index];
218+
for (var key in env) {
220219
envPairs.push(key + '=' + env[key]);
221220
}
222221

test/simple/test-child-process-env.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@ var common = require('../common');
22
var assert = require('assert');
33

44
var spawn = require('child_process').spawn;
5-
var child = spawn('/usr/bin/env', [], {env: {'HELLO': 'WORLD'}});
5+
6+
var env = {
7+
'HELLO': 'WORLD'
8+
};
9+
env.__proto__ = {
10+
'FOO': 'BAR'
11+
}
12+
13+
var child = spawn('/usr/bin/env', [], {env: env});
614

715
var response = '';
816

@@ -15,4 +23,5 @@ child.stdout.addListener('data', function(chunk) {
1523

1624
process.addListener('exit', function() {
1725
assert.ok(response.indexOf('HELLO=WORLD') >= 0);
26+
assert.ok(response.indexOf('FOO=BAR') >= 0);
1827
});

0 commit comments

Comments
 (0)