diff --git a/changelog.md b/changelog.md index ce2f6037b4..8694afa4a4 100644 --- a/changelog.md +++ b/changelog.md @@ -11,6 +11,10 @@ Features - The JS parser is from now on the new default as it is a lot faster than the hiredis parser - This is no BC as there is no changed behavior for the user at all but just a performance improvement. Explicitly requireing the Hiredis parser is still possible. +Bugfixes + +- Reverted support for `__proto__` (v.2.6.0-2) to prevent and breaking change + Deprecations - The `parser` option is deprecated and should be removed. The built-in Javascript parser is a lot faster than the hiredis parser and has more features diff --git a/lib/rawObject.js b/lib/rawObject.js deleted file mode 100644 index 26376fc360..0000000000 --- a/lib/rawObject.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -// Using a predefined object with this prototype is faster than calling `Object.create(null)` directly -// This is needed to make sure `__proto__` and similar reserved words can be used -function RawObject () {} -RawObject.prototype = Object.create(null); - -module.exports = RawObject; diff --git a/lib/utils.js b/lib/utils.js index d3d9c2fa59..fafffdac7f 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,7 +1,5 @@ 'use strict'; -var RawObject = require('./rawObject'); - // hgetall converts its replies to an Object. If the reply is empty, null is returned. // These function are only called with internal data and have therefore always the same instanceof X function replyToObject (reply) { @@ -9,7 +7,7 @@ function replyToObject (reply) { if (reply.length === 0 || !(reply instanceof Array)) { return null; } - var obj = new RawObject(); + var obj = {}; for (var i = 0; i < reply.length; i += 2) { obj[reply[i].toString('binary')] = reply[i + 1]; } diff --git a/test/commands/hgetall.spec.js b/test/commands/hgetall.spec.js index ba44326510..6c00e3ed09 100644 --- a/test/commands/hgetall.spec.js +++ b/test/commands/hgetall.spec.js @@ -22,12 +22,10 @@ describe("The 'hgetall' method", function () { }); it('handles simple keys and values', function (done) { - client.hmset(['hosts', '__proto__', '1', 'another', '23', 'home', '1234'], helper.isString('OK')); + client.hmset(['hosts', 'hasOwnProperty', '1', 'another', '23', 'home', '1234'], helper.isString('OK')); client.HGETALL(['hosts'], function (err, obj) { - if (!/^v0\.10/.test(process.version)) { - assert.strictEqual(3, Object.keys(obj).length); - assert.strictEqual('1', obj.__proto__.toString()); // eslint-disable-line no-proto - } + assert.strictEqual(3, Object.keys(obj).length); + assert.strictEqual('1', obj.hasOwnProperty.toString()); assert.strictEqual('23', obj.another.toString()); assert.strictEqual('1234', obj.home.toString()); done(err); diff --git a/test/pubsub.spec.js b/test/pubsub.spec.js index 1d33b12994..65fce29014 100644 --- a/test/pubsub.spec.js +++ b/test/pubsub.spec.js @@ -204,8 +204,8 @@ describe('publish/subscribe', function () { it('subscribe; close; resubscribe with prototype inherited property names', function (done) { var count = 0; - var channels = ['__proto__', 'channel 2']; - var msg = ['hi from channel __proto__', 'hi from channel 2']; + var channels = ['channel 1', 'channel 2']; + var msg = ['hi from channel 1', 'hi from channel 2']; sub.on('message', function (channel, message) { var n = Math.max(count - 1, 0);