qs 6.3.1 → 6.4.1

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/.editorconfig ADDED
@@ -0,0 +1,44 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = space
5
+ indent_size = 4
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+ max_line_length = 160
11
+ quote_type = single
12
+
13
+ [test/*]
14
+ max_line_length = off
15
+
16
+ [*.md]
17
+ indent_size = off
18
+ max_line_length = off
19
+
20
+ [*.json]
21
+ max_line_length = off
22
+
23
+ [Makefile]
24
+ max_line_length = off
25
+
26
+ [CHANGELOG.md]
27
+ indent_style = space
28
+ indent_size = 2
29
+
30
+ [LICENSE]
31
+ indent_size = 2
32
+ max_line_length = off
33
+
34
+ [coverage/**/*]
35
+ indent_size = off
36
+ indent_style = off
37
+ indent = off
38
+ max_line_length = off
39
+
40
+ [dist/*]
41
+ max_line_length = off
42
+
43
+ [.nycrc]
44
+ indent_style = tab
package/.eslintrc CHANGED
@@ -3,17 +3,35 @@
3
3
 
4
4
  "extends": "@ljharb",
5
5
 
6
+ "ignorePatterns": [
7
+ "dist/",
8
+ ],
9
+
6
10
  "rules": {
7
- "complexity": [2, 25],
11
+ "complexity": [2, 29],
8
12
  "consistent-return": 1,
13
+ "func-name-matching": 0,
9
14
  "id-length": [2, { "min": 1, "max": 25, "properties": "never" }],
10
15
  "indent": [2, 4],
11
- "max-params": [2, 11],
12
- "max-statements": [2, 42],
13
- "no-extra-parens": 1,
16
+ "max-lines-per-function": 0,
17
+ "max-params": [2, 12],
18
+ "max-statements": [2, 45],
19
+ "multiline-comment-style": 0,
14
20
  "no-continue": 1,
15
21
  "no-magic-numbers": 0,
22
+ "no-param-reassign": 1,
16
23
  "no-restricted-syntax": [2, "BreakStatement", "DebuggerStatement", "ForInStatement", "LabeledStatement", "WithStatement"],
17
- "operator-linebreak": 1
18
- }
24
+ },
25
+
26
+ "overrides": [
27
+ {
28
+ "files": "test/**",
29
+ "rules": {
30
+ "max-lines-per-function": 0,
31
+ "max-statements": 0,
32
+ "no-extend-native": 0,
33
+ "function-paren-newline": 0,
34
+ },
35
+ },
36
+ ],
19
37
  }
@@ -0,0 +1,12 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: [ljharb]
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: npm/qs
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ custom: # Replace with a single custom sponsorship URL
package/.nycrc ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "all": true,
3
+ "check-coverage": false,
4
+ "reporter": ["text-summary", "text", "html", "json"],
5
+ "lines": 86,
6
+ "statements": 85.93,
7
+ "functions": 82.43,
8
+ "branches": 76.06,
9
+ "exclude": [
10
+ "coverage",
11
+ "dist"
12
+ ]
13
+ }
package/CHANGELOG.md CHANGED
@@ -1,3 +1,33 @@
1
+ ## **6.4.1**
2
+ - [Fix] `parse`: ignore `__proto__` keys (#428)
3
+ - [Fix] fix for an impossible situation: when the formatter is called with a non-string value
4
+ - [Fix] use `safer-buffer` instead of `Buffer` constructor
5
+ - [Fix] `utils.merge`: avoid a crash with a null target and an array source
6
+ - [Fix]` `utils.merge`: avoid a crash with a null target and a truthy non-array source
7
+ - [Fix] `stringify`: fix a crash with `strictNullHandling` and a custom `filter`/`serializeDate` (#279)
8
+ - [Fix] `utils`: `merge`: fix crash when `source` is a truthy primitive & no options are provided
9
+ - [Fix] when `parseArrays` is false, properly handle keys ending in `[]`
10
+ - [Robustness] `stringify`: avoid relying on a global `undefined` (#427)
11
+ - [Refactor] use cached `Array.isArray`
12
+ - [Refactor] `stringify`: Avoid arr = arr.concat(...), push to the existing instance (#269)
13
+ - [readme] remove travis badge; add github actions/codecov badges; update URLs
14
+ - [Docs] Clarify the need for "arrayLimit" option
15
+ - [meta] fix README.md (#399)
16
+ - [meta] Clean up license text so it’s properly detected as BSD-3-Clause
17
+ - [meta] add FUNDING.yml
18
+ - [actions] backport actions from main
19
+ - [Tests] remove nonexistent tape option
20
+ - [Dev Deps] backport from main
21
+
22
+ ## **6.4.0**
23
+ - [New] `qs.stringify`: add `encodeValuesOnly` option
24
+ - [Fix] follow `allowPrototypes` option during merge (#201, #201)
25
+ - [Fix] support keys starting with brackets (#202, #200)
26
+ - [Fix] chmod a-x
27
+ - [Dev Deps] update `eslint`
28
+ - [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds
29
+ - [eslint] reduce warnings
30
+
1
31
  ## **6.3.1**
2
32
  - [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties (thanks, @snyk!)
3
33
  - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `browserify`, `iconv-lite`, `qs-iconv`, `tape`
@@ -24,6 +54,9 @@
24
54
  - [Tests] skip Object.create tests when null objects are not available
25
55
  - [Tests] Turn on eslint for test files (#175)
26
56
 
57
+ ## **6.2.2**
58
+ - [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
59
+
27
60
  ## **6.2.1**
28
61
  - [Fix] ensure `key[]=x&key[]&key[]=y` results in 3, not 2, values
29
62
  - [Refactor] Be explicit and use `Object.prototype.hasOwnProperty.call`
@@ -36,11 +69,18 @@
36
69
  - [New] add "encoder" and "decoder" options, for custom param encoding/decoding (#160)
37
70
  - [Fix] fix compacting of nested sparse arrays (#150)
38
71
 
72
+ ## **6.1.1**
73
+ - [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
74
+
39
75
  ## [**6.1.0**](https://github.com/ljharb/qs/issues?milestone=35&state=closed)
40
76
  - [New] allowDots option for `stringify` (#151)
41
77
  - [Fix] "sort" option should work at a depth of 3 or more (#151)
42
78
  - [Fix] Restore `dist` directory; will be removed in v7 (#148)
43
79
 
80
+ ## **6.0.3**
81
+ - [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties
82
+ - [Fix] Restore `dist` directory; will be removed in v7 (#148)
83
+
44
84
  ## [**6.0.2**](https://github.com/ljharb/qs/issues?milestone=33&state=closed)
45
85
  - Revert ES6 requirement and restore support for node down to v0.8.
46
86
 
package/LICENSE.md ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2014, Nathan LaFreniere and other [contributors](https://github.com/ljharb/qs/graphs/contributors)
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -1,4 +1,13 @@
1
- # qs
1
+ # qs <sup>[![Version Badge][2]][1]</sup>
2
+
3
+ [![github actions][actions-image]][actions-url]
4
+ [![coverage][codecov-image]][codecov-url]
5
+ [![dependency status][deps-svg]][deps-url]
6
+ [![dev dependency status][dev-deps-svg]][dev-deps-url]
7
+ [![License][license-image]][license-url]
8
+ [![Downloads][downloads-image]][downloads-url]
9
+
10
+ [![npm badge][npm-badge-png]][package-url]
2
11
 
3
12
  A querystring parsing and stringifying library with some added security.
4
13
 
@@ -169,7 +178,7 @@ assert.deepEqual(withIndexedEmptyString, { a: ['b', '', 'c'] });
169
178
  ```
170
179
 
171
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
172
- instead be converted to an object with the index as the key:
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.
173
182
 
174
183
  ```javascript
175
184
  var withMaxIndex = qs.parse('a[100]=b');
@@ -225,6 +234,15 @@ var unencoded = qs.stringify({ a: { b: 'c' } }, { encode: false });
225
234
  assert.equal(unencoded, 'a[b]=c');
226
235
  ```
227
236
 
237
+ Encoding can be disabled for keys by setting the `encodeValuesOnly` option to `true`:
238
+ ```javascript
239
+ var encodedValues = qs.stringify(
240
+ { a: 'b', c: ['d', 'e=f'], f: [['g'], ['h']] },
241
+ { encodeValuesOnly: true }
242
+ )
243
+ assert.equal(encodedValues,'a=b&c[0]=d&c[1]=e%3Df&f[0][0]=g&f[1][0]=h');
244
+ ```
245
+
228
246
  This encoding can also be replaced by a custom encoding method set as `encoder` option:
229
247
 
230
248
  ```javascript
@@ -245,6 +263,30 @@ var decoded = qs.parse('x=z', { decoder: function (str) {
245
263
  }})
246
264
  ```
247
265
 
266
+ You can encode keys and values using different logic by using the type argument provided to the encoder:
267
+
268
+ ```javascript
269
+ var encoded = qs.stringify({ a: { b: 'c' } }, { encoder: function (str, defaultEncoder, charset, type) {
270
+ if (type === 'key') {
271
+ return // Encoded key
272
+ } else if (type === 'value') {
273
+ return // Encoded value
274
+ }
275
+ }})
276
+ ```
277
+
278
+ The type argument is also provided to the decoder:
279
+
280
+ ```javascript
281
+ var decoded = qs.parse('x=z', { decoder: function (str, defaultDecoder, charset, type) {
282
+ if (type === 'key') {
283
+ return // Decoded key
284
+ } else if (type === 'value') {
285
+ return // Decoded value
286
+ }
287
+ }})
288
+ ```
289
+
248
290
  Examples beyond this point will be shown as though the output is not URI encoded for clarity. Please note that the return values in these cases *will* be URI encoded during real usage.
249
291
 
250
292
  When arrays are stringified, by default they are given explicit indices:
@@ -400,7 +442,7 @@ assert.equal(nullsSkipped, 'a=b');
400
442
 
401
443
  ### Dealing with special character sets
402
444
 
403
- By default the encoding and decoding of characters is done in `utf-8`. If you
445
+ By default the encoding and decoding of characters is done in `utf-8`. If you
404
446
  wish to encode querystrings to a different character set (i.e.
405
447
  [Shift JIS](https://en.wikipedia.org/wiki/Shift_JIS)) you can use the
406
448
  [`qs-iconv`](https://github.com/martinheidegger/qs-iconv) library:
@@ -429,3 +471,29 @@ assert.equal(qs.stringify({ a: 'b c' }), 'a=b%20c');
429
471
  assert.equal(qs.stringify({ a: 'b c' }, { format : 'RFC3986' }), 'a=b%20c');
430
472
  assert.equal(qs.stringify({ a: 'b c' }, { format : 'RFC1738' }), 'a=b+c');
431
473
  ```
474
+
475
+ ## Security
476
+
477
+ Please email [@ljharb](https://github.com/ljharb) or see https://tidelift.com/security if you have a potential security vulnerability to report.
478
+
479
+ ## qs for enterprise
480
+
481
+ Available as part of the Tidelift Subscription
482
+
483
+ The maintainers of qs and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-qs?utm_source=npm-qs&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
484
+
485
+ [package-url]: https://npmjs.org/package/qs
486
+ [npm-version-svg]: https://versionbadg.es/ljharb/qs.svg
487
+ [deps-svg]: https://david-dm.org/ljharb/qs.svg
488
+ [deps-url]: https://david-dm.org/ljharb/qs
489
+ [dev-deps-svg]: https://david-dm.org/ljharb/qs/dev-status.svg
490
+ [dev-deps-url]: https://david-dm.org/ljharb/qs#info=devDependencies
491
+ [npm-badge-png]: https://nodei.co/npm/qs.png?downloads=true&stars=true
492
+ [license-image]: https://img.shields.io/npm/l/qs.svg
493
+ [license-url]: LICENSE
494
+ [downloads-image]: https://img.shields.io/npm/dm/qs.svg
495
+ [downloads-url]: https://npm-stat.com/charts.html?package=qs
496
+ [codecov-image]: https://codecov.io/gh/ljharb/qs/branch/main/graphs/badge.svg
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
499
+ [actions-url]: https://github.com/ljharb/qs/actions
package/bower.json ADDED
@@ -0,0 +1,21 @@
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 ADDED
@@ -0,0 +1,15 @@
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
+ }