Skip to content

Commit 834389a

Browse files
committed
v6.7.3
1 parent 45143b6 commit 834389a

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
## **6.7.3**
2+
- [Fix] `parse`: ignore `__proto__` keys (#428)
3+
- [Fix] `stringify`: avoid encoding arrayformat comma when `encodeValuesOnly = true` (#424)
4+
- [Robustness] `stringify`: avoid relying on a global `undefined` (#427)
5+
- [readme] remove travis badge; add github actions/codecov badges; update URLs
6+
- [Docs] add note and links for coercing primitive values (#408)
7+
- [meta] fix README.md (#399)
8+
- [meta] do not publish workflow files
9+
- [actions] backport actions from main
10+
- [Dev Deps] backport updates from main
11+
- [Tests] use `nyc` for coverage
12+
- [Tests] clean up stringify tests slightly
13+
114
## **6.7.2**
215
- [Fix] proper comma parsing of URL-encoded commas (#361)
316
- [Fix] parses comma delimited array while having percent-encoded comma treated as normal text (#336)

component.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "qs",
3-
"repository": "hapijs/qs",
3+
"repository": "ljharb/qs",
44
"description": "query-string parser / stringifier with nesting support",
5-
"version": "6.5.0",
5+
"version": "6.7.3",
66
"keywords": ["querystring", "query", "parser"],
77
"main": "lib/index.js",
88
"scripts": [

dist/qs.js

+17-6
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ var parseObject = function (chain, val, options, valuesParsed) {
188188
) {
189189
obj = [];
190190
obj[index] = leaf;
191-
} else {
191+
} else if (cleanRoot !== '__proto__') {
192192
obj[cleanRoot] = leaf;
193193
}
194194
}
@@ -329,6 +329,7 @@ var arrayPrefixGenerators = {
329329
};
330330

331331
var isArray = Array.isArray;
332+
var split = String.prototype.split;
332333
var push = Array.prototype.push;
333334
var pushToArray = function (arr, valueOrArray) {
334335
push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
@@ -392,6 +393,14 @@ var stringify = function stringify(
392393
if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) {
393394
if (encoder) {
394395
var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset);
396+
if (generateArrayPrefix === 'comma' && encodeValuesOnly) {
397+
var valuesArray = split.call(String(obj), ',');
398+
var valuesJoined = '';
399+
for (var i = 0; i < valuesArray.length; ++i) {
400+
valuesJoined += (i === 0 ? '' : ',') + formatter(encoder(valuesArray[i], defaults.encoder, charset));
401+
}
402+
return [formatter(keyValue) + '=' + valuesJoined];
403+
}
395404
return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset))];
396405
}
397406
return [formatter(prefix) + '=' + formatter(String(obj))];
@@ -411,16 +420,17 @@ var stringify = function stringify(
411420
objKeys = sort ? keys.sort(sort) : keys;
412421
}
413422

414-
for (var i = 0; i < objKeys.length; ++i) {
415-
var key = objKeys[i];
423+
for (var j = 0; j < objKeys.length; ++j) {
424+
var key = objKeys[j];
425+
var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
416426

417427
if (skipNulls && obj[key] === null) {
418428
continue;
419429
}
420430

421431
if (isArray(obj)) {
422432
pushToArray(values, stringify(
423-
obj[key],
433+
value,
424434
typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix,
425435
generateArrayPrefix,
426436
strictNullHandling,
@@ -436,7 +446,7 @@ var stringify = function stringify(
436446
));
437447
} else {
438448
pushToArray(values, stringify(
439-
obj[key],
449+
value,
440450
prefix + (allowDots ? '.' + key : '[' + key + ']'),
441451
generateArrayPrefix,
442452
strictNullHandling,
@@ -461,7 +471,7 @@ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
461471
return defaults;
462472
}
463473

464-
if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') {
474+
if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') {
465475
throw new TypeError('Encoder has to be a function.');
466476
}
467477

@@ -752,6 +762,7 @@ var encode = function encode(str, defaultEncoder, charset) {
752762

753763
i += 1;
754764
c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
765+
/* eslint operator-linebreak: [2, "before"] */
755766
out += hexTable[0xF0 | (c >> 18)]
756767
+ hexTable[0x80 | ((c >> 12) & 0x3F)]
757768
+ hexTable[0x80 | ((c >> 6) & 0x3F)]

package.json

+1-1
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.7.2",
5+
"version": "6.7.3",
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/ljharb/qs.git"

0 commit comments

Comments
 (0)