Skip to content

child_process: do not ignore proto values of env #18210

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

Closed
Closed
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
2 changes: 1 addition & 1 deletion lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ function normalizeSpawnArguments(file, args, options) {
var env = options.env || process.env;
var envPairs = [];

for (const key of Object.keys(env)) {
for (var key in env) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a comment that flag that states that copying the prototype values is intentional.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment to the commit before landing.

const value = env[key];
if (value !== undefined) {
envPairs.push(`${key}=${value}`);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-child-process-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ child.stdout.on('data', function(chunk) {

process.on('exit', function() {
assert.ok(response.includes('HELLO=WORLD'));
assert.ok(!response.includes('FOO='));
assert.ok(response.includes('FOO=BAR'));
assert.ok(!response.includes('UNDEFINED=undefined'));
assert.ok(response.includes('NULL=null'));
assert.ok(response.includes(`EMPTY=${os.EOL}`));
Expand Down