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

src: throw on process.env symbol usage #9446

Merged
merged 1 commit into from Nov 7, 2016

Conversation

Projects
None yet
8 participants
@cjihrig
Contributor

cjihrig commented Nov 3, 2016

Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

src

Description of change

This commit causes process.env to throw when a symbol is used as either a key or a value.

Fixes: #9429

@cjihrig cjihrig added the semver-major label Nov 3, 2016

@addaleax addaleax added the process label Nov 3, 2016

@bnoordhuis

LGTM with a request.

Show outdated Hide outdated test/parallel/test-process-env-symbols.js
// Verify that assigning a symbol value throws.
assert.throws(() => {
process.env.foo = symbol;
}, /^TypeError: Cannot convert a Symbol value to a string$/);

This comment has been minimized.

@bnoordhuis

bnoordhuis Nov 3, 2016

Member

Can you also add a symbol in process.env test?

@bnoordhuis

bnoordhuis Nov 3, 2016

Member

Can you also add a symbol in process.env test?

@fhinkel

This comment has been minimized.

Show comment
Hide comment
@fhinkel

fhinkel Nov 3, 2016

Member

LGTM.

@AnnaMag, this is based on your change to use the v8::setHandler(). Very cool.

Member

fhinkel commented Nov 3, 2016

LGTM.

@AnnaMag, this is based on your change to use the v8::setHandler(). Very cool.

@jasnell

jasnell approved these changes Nov 3, 2016

I'd prefer a more specific error message but this LGTM

@cjihrig

This comment has been minimized.

Show comment
Hide comment
@cjihrig
Contributor

cjihrig commented Nov 4, 2016

@cjihrig

This comment has been minimized.

Show comment
Hide comment
@cjihrig

cjihrig Nov 4, 2016

Contributor

The first CI run was green minus related failures on Windows. Pushed a second commit with Windows only fixes. Second CI run passed on Windows: https://ci.nodejs.org/job/node-test-commit/5915/

The failures on the second run seem to be unrelated, as the second commit only touched Windows code. PTAL at the second commit.

Contributor

cjihrig commented Nov 4, 2016

The first CI run was green minus related failures on Windows. Pushed a second commit with Windows only fixes. Second CI run passed on Windows: https://ci.nodejs.org/job/node-test-commit/5915/

The failures on the second run seem to be unrelated, as the second commit only touched Windows code. PTAL at the second commit.

@danbev

This comment has been minimized.

Show comment
Hide comment
@danbev

danbev Nov 4, 2016

Member

LGTM

Member

danbev commented Nov 4, 2016

LGTM

@danbev

danbev approved these changes Nov 4, 2016

src: throw on process.env symbol usage
This commit causes process.env to throw when a symbol is used as
either a key or a value.

Fixes: #9429
PR-URL: #9446
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>

@cjihrig cjihrig merged commit 1aa595e into nodejs:master Nov 7, 2016

@cjihrig cjihrig deleted the cjihrig:symbols branch Nov 7, 2016

addaleax added a commit that referenced this pull request Nov 20, 2016

src: allow getting Symbols on process.env
1aa595e introduced a `throw` for accessing `Symbol` properties of
`process.env`. However, this breaks `util.inspect(process)` and
things like `Object.prototype.toString.call(process.env)`, so this
patch changes the behaviour for the getter to just always return
`undefined`.

Ref: #9446
Fixes: #9641
PR-URL: #9631
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

italoacasas added a commit to italoacasas/node that referenced this pull request Jan 18, 2017

src: throw on process.env symbol usage
This commit causes process.env to throw when a symbol is used as
either a key or a value.

Fixes: nodejs#9429
PR-URL: nodejs#9446
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>

italoacasas added a commit to italoacasas/node that referenced this pull request Jan 18, 2017

src: allow getting Symbols on process.env
1aa595e introduced a `throw` for accessing `Symbol` properties of
`process.env`. However, this breaks `util.inspect(process)` and
things like `Object.prototype.toString.call(process.env)`, so this
patch changes the behaviour for the getter to just always return
`undefined`.

Ref: nodejs#9446
Fixes: nodejs#9641
PR-URL: nodejs#9631
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

@TimothyGu TimothyGu referenced this pull request Mar 7, 2017

Closed

src: make process.env work with symbols for in/delete #11709

3 of 3 tasks complete

@jasnell jasnell referenced this pull request Apr 4, 2017

Closed

8.0.0 Release Proposal #12220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment