Skip to content

Commit 10233c9

Browse files
committed
v6.0.4
1 parent 2e1c659 commit 10233c9

5 files changed

Lines changed: 26 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## **6.0.4**
2+
- [Fix] follow `allowPrototypes` option during merge (#201, #200)
3+
- [Fix] chmod a-x
4+
- [Fix] support keys starting with brackets (#202, #200)
5+
- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
6+
17
## **6.0.3**
28
- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
39
- [Fix] Restore `dist` directory; will be removed in v7 (#148)

bower.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "qs",
33
"main": "dist/qs.js",
4-
"version": "5.2.0",
54
"homepage": "https://github.com/hapijs/qs",
65
"authors": [
76
"Nathan LaFreniere <quitlahok@gmail.com>"

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "qs",
33
"repository": "hapijs/qs",
44
"description": "query-string parser / stringifier with nesting support",
5-
"version": "6.0.3",
5+
"version": "6.0.4",
66
"keywords": ["querystring", "query", "parser"],
77
"main": "lib/index.js",
88
"scripts": [

dist/qs.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ var internals = {
2525
allowDots: false
2626
};
2727

28+
var has = Object.prototype.hasOwnProperty;
29+
2830
internals.parseValues = function (str, options) {
2931
var obj = {};
3032
var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
@@ -43,7 +45,7 @@ internals.parseValues = function (str, options) {
4345
var key = Utils.decode(part.slice(0, pos));
4446
var val = Utils.decode(part.slice(pos + 1));
4547

46-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
48+
if (has.call(obj, key)) {
4749
obj[key] = [].concat(obj[key]).concat(val);
4850
} else {
4951
obj[key] = val;
@@ -96,34 +98,35 @@ internals.parseKeys = function (givenKey, val, options) {
9698

9799
// The regex chunks
98100

99-
var parent = /^([^[]*)/;
101+
var brackets = /(\[[^[\]]*])/;
100102
var child = /(\[[^[\]]*])/g;
101103

102104
// Get the parent
103105

104-
var segment = parent.exec(key);
106+
var segment = brackets.exec(key);
107+
var parent = segment ? key.slice(0, segment.index) : key;
105108

106109
// Stash the parent if it exists
107110

108111
var keys = [];
109-
if (segment[1]) {
112+
if (parent) {
110113
// If we aren't using plain objects, optionally prefix keys
111114
// that would overwrite object prototype properties
112-
if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1])) {
115+
if (!options.plainObjects && has.call(Object.prototype, parent)) {
113116
if (!options.allowPrototypes) {
114117
return;
115118
}
116119
}
117120

118-
keys.push(segment[1]);
121+
keys.push(parent);
119122
}
120123

121124
// Loop through children appending to the array until we hit depth
122125

123126
var i = 0;
124127
while ((segment = child.exec(key)) !== null && i < options.depth) {
125128
i += 1;
126-
if (!options.plainObjects && Object.prototype.hasOwnProperty.call(Object.prototype, segment[1].slice(1, -1))) {
129+
if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
127130
if (!options.allowPrototypes) {
128131
return;
129132
}
@@ -319,6 +322,8 @@ var hexTable = (function () {
319322
return array;
320323
}());
321324

325+
var has = Object.prototype.hasOwnProperty;
326+
322327
exports.arrayToObject = function (source, options) {
323328
var obj = options.plainObjects ? Object.create(null) : {};
324329
for (var i = 0; i < source.length; ++i) {
@@ -339,7 +344,9 @@ exports.merge = function (target, source, options) {
339344
if (Array.isArray(target)) {
340345
target.push(source);
341346
} else if (typeof target === 'object') {
342-
target[source] = true;
347+
if (options.plainObjects || options.allowPrototypes || !has.call(Object.prototype, source)) {
348+
target[source] = true;
349+
}
343350
} else {
344351
return [target, source];
345352
}
@@ -359,7 +366,7 @@ exports.merge = function (target, source, options) {
359366
return Object.keys(source).reduce(function (acc, key) {
360367
var value = source[key];
361368

362-
if (Object.prototype.hasOwnProperty.call(acc, key)) {
369+
if (has.call(acc, key)) {
363370
acc[key] = exports.merge(acc[key], value, options);
364371
} else {
365372
acc[key] = value;

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "qs",
33
"description": "A querystring parser that supports nesting and arrays, with a depth limit",
44
"homepage": "https://github.com/ljharb/qs",
5-
"version": "6.0.3",
5+
"version": "6.0.4",
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/ljharb/qs.git"
@@ -34,7 +34,8 @@
3434
"evalmd": "^0.0.16"
3535
},
3636
"scripts": {
37-
"test": "parallelshell 'npm run readme' 'npm run lint' 'npm run coverage'",
37+
"pretest": "npm run lint && npm run readme",
38+
"test": "npm run coverage",
3839
"tests-only": "node test",
3940
"readme": "evalmd README.md",
4041
"lint": "eslint lib/*.js text/*.js",

0 commit comments

Comments
 (0)