diff options
author | Benjamin Gruenbaum <inglor@gmail.com> | 2016-03-22 15:40:36 +0200 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-03-22 11:13:03 -0700 |
commit | c9c387fdac7d8deee6ee1a60026c01fa98d4d1b1 (patch) | |
tree | 6c1b4679a74c8357fc8ee5c5332f0a1a00e2917a /test/parallel/test-c-ares.js | |
parent | 4985c3411fdde93150c9cc693e0c1f23b4b27a16 (diff) | |
download | android-node-v8-c9c387fdac7d8deee6ee1a60026c01fa98d4d1b1.tar.gz android-node-v8-c9c387fdac7d8deee6ee1a60026c01fa98d4d1b1.tar.bz2 android-node-v8-c9c387fdac7d8deee6ee1a60026c01fa98d4d1b1.zip |
dns: Use object without protoype for map
Currently we use `{}` for the `lookup` function to find the relevant
resolver to the dns.resolve function. It is preferable to use an
object without a Object.prototype, currently for example you can do
something like:
```js
dns.resolve("google.com", "toString", console.log);
```
And get `[Object undefined]` logged and the callback would never be
called. This is unexpected and strange behavior in my opinion.
In addition, if someone adds a property to `Object.prototype` might
also create unexpected results.
This pull request fixes it, with it an appropriate error is thrown.
PR-URL: https://github.com/nodejs/node/pull/5843
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaƫl Zasso <mic.besace@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test/parallel/test-c-ares.js')
-rw-r--r-- | test/parallel/test-c-ares.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/parallel/test-c-ares.js b/test/parallel/test-c-ares.js index 8c2178ead6..66ae0e0a4a 100644 --- a/test/parallel/test-c-ares.js +++ b/test/parallel/test-c-ares.js @@ -27,6 +27,11 @@ assert.throws(function() { dns.resolve('www.google.com', 'HI'); }, /Unknown type/); +// Try calling resolve with an unsupported type that's an object key +assert.throws(function() { + dns.resolve('www.google.com', 'toString'); +}, /Unknown type/); + // Windows doesn't usually have an entry for localhost 127.0.0.1 in // C:\Windows\System32\drivers\etc\hosts // so we disable this test on Windows. |