From be1c4211a6031cac3443ce66220f4954338bde3f Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 15 Feb 2017 22:45:41 -0800 Subject: [PATCH] v6.0.3 --- CHANGELOG.md | 4 ++++ component.json | 2 +- dist/qs.js | 10 +++++----- package.json | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2df5e9d3..f0d0bf9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## **6.0.3** +- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties +- [Fix] Restore `dist` directory; will be removed in v7 (#148) + ## [**6.0.2**](https://github.com/ljharb/qs/issues?milestone=33&state=closed) - Revert ES6 requirement and restore support for node down to v0.8. diff --git a/component.json b/component.json index fca856a6..90758a9b 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "qs", "repository": "hapijs/qs", "description": "query-string parser / stringifier with nesting support", - "version": "5.2.0", + "version": "6.0.3", "keywords": ["querystring", "query", "parser"], "main": "lib/index.js", "scripts": [ diff --git a/dist/qs.js b/dist/qs.js index 68433d45..1bf41da7 100644 --- a/dist/qs.js +++ b/dist/qs.js @@ -67,7 +67,7 @@ internals.parseObject = function (chain, val, options) { obj = obj.concat(internals.parseObject(chain, val, options)); } else { obj = options.plainObjects ? Object.create(null) : {}; - var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root; + var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root; var index = parseInt(cleanRoot, 10); if ( !isNaN(index) && @@ -96,8 +96,8 @@ internals.parseKeys = function (givenKey, val, options) { // The regex chunks - var parent = /^([^\[\]]*)/; - var child = /(\[[^\[\]]*\])/g; + var parent = /^([^[]*)/; + var child = /(\[[^[\]]*])/g; // Get the parent @@ -123,9 +123,9 @@ internals.parseKeys = function (givenKey, val, options) { var i = 0; while ((segment = child.exec(key)) !== null && i < options.depth) { i += 1; - if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) { + if (!options.plainObjects && Object.prototype.hasOwnProperty.call(Object.prototype, segment[1].slice(1, -1))) { if (!options.allowPrototypes) { - continue; + return; } } keys.push(segment[1]); diff --git a/package.json b/package.json index e941ea92..377dabef 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "qs", "description": "A querystring parser that supports nesting and arrays, with a depth limit", "homepage": "https://github.com/ljharb/qs", - "version": "6.0.2", + "version": "6.0.3", "repository": { "type": "git", "url": "https://github.com/ljharb/qs.git"