Permalink
Please
sign in to comment.
Browse files
util: protect against monkeypatched Object prototype for inspect()
Prevent affects of monkeypatching (for example) Object.keys() when calling util.inspect(). PR-URL: #25953 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- Loading branch information...
Showing
with
19 additions
and 7 deletions.
| @@ -0,0 +1,11 @@ | |||
| 'use strict'; | |||
|
|
|||
| // Monkeypatch Object.keys() so that it throws an unexpected error. This tests | |||
| // that `util.inspect()` is unaffected by monkey-patching `Object`. | |||
|
|
|||
| require('../common'); | |||
| const assert = require('assert'); | |||
| const util = require('util'); | |||
|
|
|||
| Object.keys = () => { throw new Error('fhqwhgads'); }; | |||
| assert.strictEqual(util.inspect({}), '{}'); | |||
0 comments on commit
1847696