fix(parseKeyValue): ignore properties in prototype chain.

Previously, properties (typically functions) in the prototype chain (Object.prototype) would shadow
query parameters, and cause them to be serialized incorrectly.

This CL guards against this by using hasOwnProperty() to ensure that only own properties are a concern.

Closes #8070
Fixes #8068
This commit is contained in:
Caitlin Potter
2014-07-03 17:22:16 -04:00
parent 9063a0c2e7
commit 873acf8fab
2 changed files with 8 additions and 1 deletions

View File

@@ -1105,7 +1105,7 @@ function parseKeyValue(/**string*/keyValue) {
key = tryDecodeURIComponent(key_value[0]);
if ( isDefined(key) ) {
var val = isDefined(key_value[1]) ? tryDecodeURIComponent(key_value[1]) : true;
if (!obj[key]) {
if (!hasOwnProperty.call(obj, key)) {
obj[key] = val;
} else if(isArray(obj[key])) {
obj[key].push(val);