tj / node-querystring

querystring parser for node and the browser - supporting nesting (used by Express, Connect, etc)
MIT License
455 stars 66 forks source link

Object.create behavior change breaks querystring.parse in chrome #70

Closed ashaffer closed 10 years ago

ashaffer commented 11 years ago

In the latest version of Chrome they have subtly changed the behavior of proto. It is now defined as an accessor on Object.prototype, which means that when you do an Object.create(null) proto is no longer a special property, which means that querystring.parse returns an object with a property called 'proto' that still has a null prototype chain.

I'm running on chrome Version 28.0.1500.52 beta on Ubuntu. A simple test to see if your version of chrome is effected by this is

(function () {
  var o = Object.create(null);
  o.__proto__ = Object.prototype;
  return o.hasOwnProperty === undefined
})()

v8 bug report on the issue confirming the behavior is expected: https://code.google.com/p/v8/issues/detail?id=2727

halfdan commented 10 years ago

Is there an update on this? This happens in node.js (v0.11.3) as well:

> qs.parse('user[name][first]=Tobi&user[email]=tobi@learnboost.com');
{ user: 
   { name: { first: 'Tobi', [__proto__]: {} },
     email: 'tobi@learnboost.com',
     [__proto__]: {} },
  [__proto__]: {} }

(example from README)

halfdan commented 10 years ago

@visionmedia Just noticed a fix has already been applied. Would it be possible to release a new version?

buschtoens commented 10 years ago

Closed by #86.