forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Minwoo Jung <[email protected]>
- Loading branch information
Showing
3 changed files
with
32 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
require('../common'); | ||
|
||
const assert = require('assert'); | ||
const symbol = Symbol('sym'); | ||
const errRegExp = /^TypeError: Cannot convert a Symbol value to a string$/; | ||
|
||
// Verify that getting via a symbol key throws. | ||
assert.throws(() => { | ||
process.env[symbol]; | ||
}, errRegExp); | ||
|
||
// Verify that assigning via a symbol key throws. | ||
assert.throws(() => { | ||
process.env[symbol] = 42; | ||
}, errRegExp); | ||
|
||
// Verify that assigning a symbol value throws. | ||
assert.throws(() => { | ||
process.env.foo = symbol; | ||
}, errRegExp); | ||
|
||
// Verify that using a symbol with the in operator throws. | ||
assert.throws(() => { | ||
symbol in process.env; | ||
}, errRegExp); |
This file was deleted.
Oops, something went wrong.