qs 6.4.1 → 6.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## **6.4.3**
2
+ - [Fix] fix regressions from robustness refactor
3
+ - [meta] add `npmignore` to autogenerate an npmignore file
4
+ - [actions] update reusable workflows
5
+
6
+ ## **6.4.2**
7
+ - [Robustness] avoid `.push`, use `void`
8
+ - [readme] clarify `parseArrays` and `arrayLimit` documentation (#543)
9
+ - [readme] replace runkit CI badge with shields.io check-runs badge
10
+ - [readme] replace travis CI badge with shields.io check-runs badge
11
+ - [actions] fix rebase workflow permissions
12
+
1
13
  ## **6.4.1**
2
14
  - [Fix] `parse`: ignore `__proto__` keys (#428)
3
15
  - [Fix] fix for an impossible situation: when the formatter is called with a non-string value
package/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  A querystring parsing and stringifying library with some added security.
13
13
 
14
- [![Build Status](https://api.travis-ci.org/ljharb/qs.svg)](http://travis-ci.org/ljharb/qs)
14
+ [![Build Status](https://img.shields.io/github/check-runs/ljharb/qs/main)](https://github.com/ljharb/qs/actions)
15
15
 
16
16
  Lead Maintainer: [Jordan Harband](https://github.com/ljharb)
17
17
 
@@ -177,7 +177,7 @@ var withIndexedEmptyString = qs.parse('a[0]=b&a[1]=&a[2]=c');
177
177
  assert.deepEqual(withIndexedEmptyString, { a: ['b', '', 'c'] });
178
178
  ```
179
179
 
180
- **qs** will also limit specifying indices in an array to a maximum index of `20`. Any array members with an index of greater than `20` will
180
+ **qs** will also limit arrays to a maximum of `20` elements. Any array members with an index of `20` or greater will
181
181
  instead be converted to an object with the index as the key. This is needed to handle cases when someone sent, for example, `a[999999999]` and it will take significant time to iterate over this huge array.
182
182
 
183
183
  ```javascript
@@ -192,7 +192,7 @@ var withArrayLimit = qs.parse('a[1]=b', { arrayLimit: 0 });
192
192
  assert.deepEqual(withArrayLimit, { a: { '1': 'b' } });
193
193
  ```
194
194
 
195
- To disable array parsing entirely, set `parseArrays` to `false`.
195
+ To prevent array syntax (`a[]`, `a[0]`) from being parsed as arrays, set `parseArrays` to `false`.
196
196
 
197
197
  ```javascript
198
198
  var noParsingArrays = qs.parse('a[]=b', { parseArrays: false });
@@ -495,5 +495,5 @@ The maintainers of qs and thousands of other packages are working with Tidelift
495
495
  [downloads-url]: https://npm-stat.com/charts.html?package=qs
496
496
  [codecov-image]: https://codecov.io/gh/ljharb/qs/branch/main/graphs/badge.svg
497
497
  [codecov-url]: https://app.codecov.io/gh/ljharb/qs/
498
- [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/qs
498
+ [actions-image]: https://img.shields.io/github/check-runs/ljharb/qs/main
499
499
  [actions-url]: https://github.com/ljharb/qs/actions
package/dist/qs.js CHANGED
@@ -52,7 +52,7 @@ var defaults = {
52
52
 
53
53
  var parseValues = function parseQueryStringValues(str, options) {
54
54
  var obj = {};
55
- var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
55
+ var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? void undefined : options.parameterLimit);
56
56
 
57
57
  for (var i = 0; i < parts.length; ++i) {
58
58
  var part = parts[i];
@@ -139,7 +139,7 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
139
139
  }
140
140
  }
141
141
 
142
- keys.push(parent);
142
+ keys[keys.length] = parent;
143
143
  }
144
144
 
145
145
  // Loop through children appending to the array until we hit depth
@@ -152,13 +152,13 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
152
152
  return;
153
153
  }
154
154
  }
155
- keys.push(segment[1]);
155
+ keys[keys.length] = segment[1];
156
156
  }
157
157
 
158
158
  // If there's a remainder, just add whatever is left
159
159
 
160
160
  if (segment) {
161
- keys.push('[' + key.slice(segment.index) + ']');
161
+ keys[keys.length] = '[' + key.slice(segment.index) + ']';
162
162
  }
163
163
 
164
164
  return parseObject(keys, val, options);
@@ -425,7 +425,7 @@ var has = Object.prototype.hasOwnProperty;
425
425
  var hexTable = (function () {
426
426
  var array = [];
427
427
  for (var i = 0; i < 256; ++i) {
428
- array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
428
+ array[array.length] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase();
429
429
  }
430
430
 
431
431
  return array;
@@ -449,7 +449,7 @@ exports.merge = function (target, source, options) {
449
449
 
450
450
  if (typeof source !== 'object') {
451
451
  if (Array.isArray(target)) {
452
- target.push(source);
452
+ target[target.length] = source;
453
453
  } else if (target && typeof target === 'object') {
454
454
  if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {
455
455
  target[source] = true;
@@ -476,7 +476,7 @@ exports.merge = function (target, source, options) {
476
476
  if (target[i] && typeof target[i] === 'object') {
477
477
  target[i] = exports.merge(target[i], item, options);
478
478
  } else {
479
- target.push(item);
479
+ target[target.length] = item;
480
480
  }
481
481
  } else {
482
482
  target[i] = item;
@@ -569,16 +569,16 @@ exports.compact = function (obj, references) {
569
569
  return refs[lookup];
570
570
  }
571
571
 
572
- refs.push(obj);
572
+ refs[refs.length] = obj;
573
573
 
574
574
  if (Array.isArray(obj)) {
575
575
  var compacted = [];
576
576
 
577
577
  for (var i = 0; i < obj.length; ++i) {
578
578
  if (obj[i] && typeof obj[i] === 'object') {
579
- compacted.push(exports.compact(obj[i], refs));
579
+ compacted[compacted.length] = exports.compact(obj[i], refs);
580
580
  } else if (typeof obj[i] !== 'undefined') {
581
- compacted.push(obj[i]);
581
+ compacted[compacted.length] = obj[i];
582
582
  }
583
583
  }
584
584
 
package/lib/parse.js CHANGED
@@ -18,7 +18,7 @@ var defaults = {
18
18
 
19
19
  var parseValues = function parseQueryStringValues(str, options) {
20
20
  var obj = {};
21
- var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
21
+ var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? void undefined : options.parameterLimit);
22
22
 
23
23
  for (var i = 0; i < parts.length; ++i) {
24
24
  var part = parts[i];
@@ -105,7 +105,7 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
105
105
  }
106
106
  }
107
107
 
108
- keys.push(parent);
108
+ keys[keys.length] = parent;
109
109
  }
110
110
 
111
111
  // Loop through children appending to the array until we hit depth
@@ -118,13 +118,13 @@ var parseKeys = function parseQueryStringKeys(givenKey, val, options) {
118
118
  return;
119
119
  }
120
120
  }
121
- keys.push(segment[1]);
121
+ keys[keys.length] = segment[1];
122
122
  }
123
123
 
124
124
  // If there's a remainder, just add whatever is left
125
125
 
126
126
  if (segment) {
127
- keys.push('[' + key.slice(segment.index) + ']');
127
+ keys[keys.length] = '[' + key.slice(segment.index) + ']';
128
128
  }
129
129
 
130
130
  return parseObject(keys, val, options);
package/lib/utils.js CHANGED
@@ -5,7 +5,7 @@ var has = Object.prototype.hasOwnProperty;
5
5
  var hexTable = (function () {
6
6
  var array = [];
7
7
  for (var i = 0; i < 256; ++i) {
8
- array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
8
+ array[array.length] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase();
9
9
  }
10
10
 
11
11
  return array;
@@ -29,7 +29,7 @@ exports.merge = function (target, source, options) {
29
29
 
30
30
  if (typeof source !== 'object') {
31
31
  if (Array.isArray(target)) {
32
- target.push(source);
32
+ target[target.length] = source;
33
33
  } else if (target && typeof target === 'object') {
34
34
  if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) {
35
35
  target[source] = true;
@@ -56,7 +56,7 @@ exports.merge = function (target, source, options) {
56
56
  if (target[i] && typeof target[i] === 'object') {
57
57
  target[i] = exports.merge(target[i], item, options);
58
58
  } else {
59
- target.push(item);
59
+ target[target.length] = item;
60
60
  }
61
61
  } else {
62
62
  target[i] = item;
@@ -149,16 +149,16 @@ exports.compact = function (obj, references) {
149
149
  return refs[lookup];
150
150
  }
151
151
 
152
- refs.push(obj);
152
+ refs[refs.length] = obj;
153
153
 
154
154
  if (Array.isArray(obj)) {
155
155
  var compacted = [];
156
156
 
157
157
  for (var i = 0; i < obj.length; ++i) {
158
158
  if (obj[i] && typeof obj[i] === 'object') {
159
- compacted.push(exports.compact(obj[i], refs));
159
+ compacted[compacted.length] = exports.compact(obj[i], refs);
160
160
  } else if (typeof obj[i] !== 'undefined') {
161
- compacted.push(obj[i]);
161
+ compacted[compacted.length] = obj[i];
162
162
  }
163
163
  }
164
164
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "qs",
3
3
  "description": "A querystring parser that supports nesting and arrays, with a depth limit",
4
4
  "homepage": "https://github.com/ljharb/qs",
5
- "version": "6.4.1",
5
+ "version": "6.4.3",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/ljharb/qs.git"
@@ -36,10 +36,11 @@
36
36
  "qs-iconv": "^1.0.4",
37
37
  "safe-publish-latest": "^2.0.0",
38
38
  "safer-buffer": "^2.1.2",
39
- "tape": "^5.4.0"
39
+ "tape": "^5.4.0",
40
+ "npmignore": "^0.3.1"
40
41
  },
41
42
  "scripts": {
42
- "prepublishOnly": "safe-publish-latest && npm run dist",
43
+ "prepublishOnly": "safe-publish-latest && npmignore --auto --commentLines=autogenerated && npm run dist",
43
44
  "prepublish": "not-in-publish || npm run prepublishOnly",
44
45
  "pretest": "npm run --silent readme && npm run --silent lint",
45
46
  "test": "npm run --silent tests-only",
@@ -50,5 +51,13 @@
50
51
  "lint": "eslint --ext=js,mjs .",
51
52
  "dist": "mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js"
52
53
  },
53
- "license": "BSD-3-Clause"
54
+ "license": "BSD-3-Clause",
55
+ "publishConfig": {
56
+ "ignore": [
57
+ "!dist/*",
58
+ "bower.json",
59
+ "component.json",
60
+ ".github/workflows"
61
+ ]
62
+ }
54
63
  }
package/test/parse.js CHANGED
@@ -51,6 +51,15 @@ test('parse()', function (t) {
51
51
  st.end();
52
52
  });
53
53
 
54
+ t.test('correctly computes the remainder when depth is exceeded', function (st) {
55
+ st.deepEqual(
56
+ qs.parse('a[b][c][d][e]=f', { depth: 2 }),
57
+ { a: { b: { c: { '[d][e]': 'f' } } } },
58
+ 'the remainder is "[d][e]", not the full original key'
59
+ );
60
+ st.end();
61
+ });
62
+
54
63
  t.deepEqual(qs.parse('a=b&a=c'), { a: ['b', 'c'] }, 'parses a simple array');
55
64
 
56
65
  t.test('parses an explicit array', function (st) {
package/test/stringify.js CHANGED
@@ -18,6 +18,12 @@ test('stringify()', function (t) {
18
18
  st.end();
19
19
  });
20
20
 
21
+ t.test('correctly encodes low-byte characters', function (st) {
22
+ st.equal(qs.stringify({ a: String.fromCharCode(1) }), 'a=%01', 'encodes 0x01');
23
+ st.equal(qs.stringify({ a: String.fromCharCode(15) }), 'a=%0F', 'encodes 0x0F');
24
+ st.end();
25
+ });
26
+
21
27
  t.test('stringifies a nested object', function (st) {
22
28
  st.equal(qs.stringify({ a: { b: 'c' } }), 'a%5Bb%5D=c');
23
29
  st.equal(qs.stringify({ a: { b: { c: { d: 'e' } } } }), 'a%5Bb%5D%5Bc%5D%5Bd%5D=e');
package/bower.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "name": "qs",
3
- "main": "dist/qs.js",
4
- "homepage": "https://github.com/hapijs/qs",
5
- "authors": [
6
- "Nathan LaFreniere <quitlahok@gmail.com>"
7
- ],
8
- "description": "A querystring parser that supports nesting and arrays, with a depth limit",
9
- "keywords": [
10
- "querystring",
11
- "qs"
12
- ],
13
- "license": "BSD-3-Clause",
14
- "ignore": [
15
- "**/.*",
16
- "node_modules",
17
- "bower_components",
18
- "test",
19
- "tests"
20
- ]
21
- }
package/component.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "name": "qs",
3
- "repository": "hapijs/qs",
4
- "description": "query-string parser / stringifier with nesting support",
5
- "version": "6.4.1",
6
- "keywords": ["querystring", "query", "parser"],
7
- "main": "lib/index.js",
8
- "scripts": [
9
- "lib/index.js",
10
- "lib/parse.js",
11
- "lib/stringify.js",
12
- "lib/utils.js"
13
- ],
14
- "license": "BSD-3-Clause"
15
- }