Commit f0bd6e1
authored
fix: exclude __proto__ from walk() (#2699)
[`__proto__`] is a special property to access an object's prototype. It
has many pitfalls:
- Setting it to an object value changes an object's prototype, which is
generally discouraged and may be unexpected by the `iterator` callback.
- Setting it to a non-object value does nothing (meaning `seen[k] =
true` has no effect).
- When Node.js is run with the [`--disable-proto=throw`] option, getting
or setting `__proto__` causes an exception with code
`ERR_PROTO_ACCESS` to be thrown.
Additionally, since this property (and all properties of
`Object.prototype`) are currently unused in this project by consumers of
`walk()`, it is both safe and preferable to exclude.
[`__proto__`]: https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.prototype.__proto__
[`--disable-proto=throw`]: https://nodejs.org/api/cli.html#disable-protomode
Fixes: #2695
Signed-off-by: Kevin Locke <kevin@kevinlocke.name>1 parent 1f8afd5 commit f0bd6e1
1 file changed
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
32 | 38 | | |
33 | 39 | | |
34 | 40 | | |
| |||
0 commit comments