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

Commit

Permalink
Read up the prototype of the 'env' object.
Browse files Browse the repository at this point in the history
Closes GH-713.
  • Loading branch information
TooTallNate authored and ry committed Feb 25, 2011
1 parent 8a50f23 commit a9a252f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ ChildProcess.prototype.spawn = function(path, args, options, customFds) {

var envPairs = [];
var keys = Object.keys(env);
for (var index = 0, keysLength = keys.length; index < keysLength; index++) {
var key = keys[index];
for (var key in env) {
envPairs.push(key + '=' + env[key]);
}

Expand Down
11 changes: 10 additions & 1 deletion test/simple/test-child-process-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ var common = require('../common');
var assert = require('assert');

var spawn = require('child_process').spawn;
var child = spawn('/usr/bin/env', [], {env: {'HELLO': 'WORLD'}});

var env = {
'HELLO': 'WORLD'
};
env.__proto__ = {
'FOO': 'BAR'
}

var child = spawn('/usr/bin/env', [], {env: env});

var response = '';

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

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

0 comments on commit a9a252f

Please sign in to comment.