diff options
Diffstat (limited to 'deps/npm/node_modules/request/node_modules/qs')
13 files changed, 481 insertions, 99 deletions
diff --git a/deps/npm/node_modules/request/node_modules/qs/.jscs.json b/deps/npm/node_modules/request/node_modules/qs/.jscs.json new file mode 100644 index 0000000000..7296cbab09 --- /dev/null +++ b/deps/npm/node_modules/request/node_modules/qs/.jscs.json @@ -0,0 +1,175 @@ +{ + "es3": true, + + "additionalRules": [], + + "requireSemicolons": true, + + "disallowMultipleSpaces": true, + + "disallowIdentifierNames": [], + + "requireCurlyBraces": { + "allExcept": [], + "keywords": ["if", "else", "for", "while", "do", "try", "catch"] + }, + + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], + + "disallowSpaceAfterKeywords": [], + + "disallowSpaceBeforeComma": true, + "disallowSpaceAfterComma": false, + "disallowSpaceBeforeSemicolon": true, + + "disallowNodeTypes": [ + "DebuggerStatement", + "ForInStatement", + "LabeledStatement", + "SwitchCase", + "SwitchStatement", + "WithStatement" + ], + + "requireObjectKeysOnNewLine": { "allExcept": ["sameLine"] }, + + "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, + "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, + + "requireSpaceBetweenArguments": true, + + "disallowSpacesInsideParentheses": true, + + "disallowSpacesInsideArrayBrackets": true, + + "disallowQuotedKeysInObjects": { "allExcept": ["reserved"] }, + + "disallowSpaceAfterObjectKeys": true, + + "requireCommaBeforeLineBreak": true, + + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "requireSpaceAfterPrefixUnaryOperators": [], + + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "requireSpaceBeforePostfixUnaryOperators": [], + + "disallowSpaceBeforeBinaryOperators": [], + "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + + "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], + "disallowSpaceAfterBinaryOperators": [], + + "disallowImplicitTypeConversion": ["binary", "string"], + + "disallowKeywords": ["with", "eval"], + + "requireKeywordsOnNewLine": [], + "disallowKeywordsOnNewLine": ["else"], + + "requireLineFeedAtFileEnd": true, + + "disallowTrailingWhitespace": true, + + "disallowTrailingComma": true, + + "excludeFiles": ["node_modules/**", "vendor/**"], + + "disallowMultipleLineStrings": true, + + "requireDotNotation": { "allExcept": ["keywords"] }, + + "requireParenthesesAroundIIFE": true, + + "validateLineBreaks": "LF", + + "validateQuoteMarks": { + "escape": true, + "mark": "'" + }, + + "disallowOperatorBeforeLineBreak": [], + + "requireSpaceBeforeKeywords": [ + "do", + "for", + "if", + "else", + "switch", + "case", + "try", + "catch", + "finally", + "while", + "with", + "return" + ], + + "validateAlignedFunctionParameters": { + "lineBreakAfterOpeningBraces": true, + "lineBreakBeforeClosingBraces": true + }, + + "requirePaddingNewLinesBeforeExport": true, + + "validateNewlineAfterArrayElements": { + "maximum": 1 + }, + + "requirePaddingNewLinesAfterUseStrict": true, + + "disallowArrowFunctions": true, + + "disallowMultiLineTernary": true, + + "validateOrderInObjectKeys": "asc-insensitive", + + "disallowIdenticalDestructuringNames": true, + + "disallowNestedTernaries": { "maxLevel": 1 }, + + "requireSpaceAfterComma": { "allExcept": ["trailing"] }, + "requireAlignedMultilineParams": false, + + "requireSpacesInGenerator": { + "afterStar": true + }, + + "disallowSpacesInGenerator": { + "beforeStar": true + }, + + "disallowVar": false, + + "requireArrayDestructuring": false, + + "requireEnhancedObjectLiterals": false, + + "requireObjectDestructuring": false, + + "requireEarlyReturn": false, + + "requireCapitalizedConstructorsNew": { + "allExcept": ["Function", "String", "Object", "Symbol", "Number", "Date", "RegExp", "Error", "Boolean", "Array"] + }, + + "requireImportAlphabetized": false, + + "requireSpaceBeforeObjectValues": true, + "requireSpaceBeforeDestructuredValues": true, + + "disallowSpacesInsideTemplateStringPlaceholders": true, + + "disallowArrayDestructuringReturn": false, + + "requireNewlineBeforeSingleStatementsInIf": false, + + "disallowUnusedVariables": true, + + "requireSpacesInsideImportedObjectBraces": true, + + "requireUseStrict": true +} diff --git a/deps/npm/node_modules/request/node_modules/qs/CHANGELOG.md b/deps/npm/node_modules/request/node_modules/qs/CHANGELOG.md index 351edd4e6a..85e69b0a22 100644 --- a/deps/npm/node_modules/request/node_modules/qs/CHANGELOG.md +++ b/deps/npm/node_modules/request/node_modules/qs/CHANGELOG.md @@ -1,3 +1,24 @@ +## **6.4.0** +- [New] `qs.stringify`: add `encodeValuesOnly` option +- [Fix] follow `allowPrototypes` option during merge (#201, #201) +- [Fix] support keys starting with brackets (#202, #200) +- [Fix] chmod a-x +- [Dev Deps] update `eslint` +- [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds +- [eslint] reduce warnings + +## **6.3.1** +- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties (thanks, @snyk!) +- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `browserify`, `iconv-lite`, `qs-iconv`, `tape` +- [Tests] on all node minors; improve test matrix +- [Docs] document stringify option `allowDots` (#195) +- [Docs] add empty object and array values example (#195) +- [Docs] Fix minor inconsistency/typo (#192) +- [Docs] document stringify option `sort` (#191) +- [Refactor] `stringify`: throw faster with an invalid encoder +- [Refactor] remove unnecessary escapes (#184) +- Remove contributing.md, since `qs` is no longer part of `hapi` (#183) + ## **6.3.0** - [New] Add support for RFC 1738 (#174, #173) - [New] `stringify`: Add `serializeDate` option to customize Date serialization (#159) @@ -12,6 +33,9 @@ - [Tests] skip Object.create tests when null objects are not available - [Tests] Turn on eslint for test files (#175) +## **6.2.2** +- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties + ## **6.2.1** - [Fix] ensure `key[]=x&key[]&key[]=y` results in 3, not 2, values - [Refactor] Be explicit and use `Object.prototype.hasOwnProperty.call` @@ -24,11 +48,18 @@ - [New] add "encoder" and "decoder" options, for custom param encoding/decoding (#160) - [Fix] fix compacting of nested sparse arrays (#150) +## **6.1.1** +- [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties + ## [**6.1.0**](https://github.com/ljharb/qs/issues?milestone=35&state=closed) - [New] allowDots option for `stringify` (#151) - [Fix] "sort" option should work at a depth of 3 or more (#151) - [Fix] Restore `dist` directory; will be removed in v7 (#148) +## **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/deps/npm/node_modules/request/node_modules/qs/CONTRIBUTING.md b/deps/npm/node_modules/request/node_modules/qs/CONTRIBUTING.md deleted file mode 100644 index 892836159b..0000000000 --- a/deps/npm/node_modules/request/node_modules/qs/CONTRIBUTING.md +++ /dev/null @@ -1 +0,0 @@ -Please view our [hapijs contributing guide](https://github.com/hapijs/hapi/blob/master/CONTRIBUTING.md). diff --git a/deps/npm/node_modules/request/node_modules/qs/README.md b/deps/npm/node_modules/request/node_modules/qs/README.md index ac1e7f1670..32fc3123fe 100644 --- a/deps/npm/node_modules/request/node_modules/qs/README.md +++ b/deps/npm/node_modules/request/node_modules/qs/README.md @@ -225,6 +225,15 @@ var unencoded = qs.stringify({ a: { b: 'c' } }, { encode: false }); assert.equal(unencoded, 'a[b]=c'); ``` +Encoding can be disabled for keys by setting the `encodeValuesOnly` option to `true`: +```javascript +var encodedValues = qs.stringify( + { a: 'b', c: ['d', 'e=f'], f: [['g'], ['h']] }, + { encodeValuesOnly: true } +) +assert.equal(encodedValues,'a=b&c[0]=d&c[1]=e%3Df&f[0][0]=g&f[1][0]=h'); +``` + This encoding can also be replaced by a custom encoding method set as `encoder` option: ```javascript @@ -261,7 +270,7 @@ qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false }); // 'a=b&a=c&a=d' ``` -You may use the `arrayFormat` option to specify the format of the output array +You may use the `arrayFormat` option to specify the format of the output array: ```javascript qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' }) @@ -272,12 +281,36 @@ qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' }) // 'a=b&a=c' ``` +When objects are stringified, by default they use bracket notation: + +```javascript +qs.stringify({ a: { b: { c: 'd', e: 'f' } } }); +// 'a[b][c]=d&a[b][e]=f' +``` + +You may override this to use dot notation by setting the `allowDots` option to `true`: + +```javascript +qs.stringify({ a: { b: { c: 'd', e: 'f' } } }, { allowDots: true }); +// 'a.b.c=d&a.b.e=f' +``` + Empty strings and null values will omit the value, but the equals sign (=) remains in place: ```javascript assert.equal(qs.stringify({ a: '' }), 'a='); ``` +Key with no values (such as an empty object or array) will return nothing: + +```javascript +assert.equal(qs.stringify({ a: [] }), ''); +assert.equal(qs.stringify({ a: {} }), ''); +assert.equal(qs.stringify({ a: [{}] }), ''); +assert.equal(qs.stringify({ a: { b: []} }), ''); +assert.equal(qs.stringify({ a: { b: {}} }), ''); +``` + Properties that are set to `undefined` will be omitted entirely: ```javascript @@ -301,6 +334,15 @@ assert.equal( ); ``` +You may use the `sort` option to affect the order of parameter keys: + +```javascript +function alphabeticalSort(a, b) { + return a.localeCompare(b); +} +assert.equal(qs.stringify({ a: 'c', z: 'y', b : 'f' }, { sort: alphabeticalSort }), 'a=c&b=f&z=y'); +``` + Finally, you can use the `filter` option to restrict which keys will be included in the stringified output. If you pass a function, it will be called for each key to obtain the replacement value. Otherwise, if you pass an array, it will be used to select properties and array indices for stringification: @@ -367,7 +409,7 @@ assert.equal(nullsSkipped, 'a=b'); ### Dealing with special character sets -By default the encoding and decoding of characters is done in `utf-8`. If you +By default the encoding and decoding of characters is done in `utf-8`. If you wish to encode querystrings to a different character set (i.e. [Shift JIS](https://en.wikipedia.org/wiki/Shift_JIS)) you can use the [`qs-iconv`](https://github.com/martinheidegger/qs-iconv) library: diff --git a/deps/npm/node_modules/request/node_modules/qs/dist/qs.js b/deps/npm/node_modules/request/node_modules/qs/dist/qs.js index 1a80d2d8bf..2d0d63ff26 100644 --- a/deps/npm/node_modules/request/node_modules/qs/dist/qs.js +++ b/deps/npm/node_modules/request/node_modules/qs/dist/qs.js @@ -50,7 +50,7 @@ var defaults = { strictNullHandling: false }; -var parseValues = function parseValues(str, options) { +var parseValues = function parseQueryStringValues(str, options) { var obj = {}; var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit); @@ -76,7 +76,7 @@ var parseValues = function parseValues(str, options) { return obj; }; -var parseObject = function parseObject(chain, val, options) { +var parseObject = function parseObjectRecursive(chain, val, options) { if (!chain.length) { return val; } @@ -89,7 +89,7 @@ var parseObject = function parseObject(chain, val, options) { obj = obj.concat(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) && @@ -108,36 +108,37 @@ var parseObject = function parseObject(chain, val, options) { return obj; }; -var parseKeys = function parseKeys(givenKey, val, options) { +var parseKeys = function parseQueryStringKeys(givenKey, val, options) { if (!givenKey) { return; } // Transform dot notation to bracket notation - var key = options.allowDots ? givenKey.replace(/\.([^\.\[]+)/g, '[$1]') : givenKey; + var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey; // The regex chunks - var parent = /^([^\[\]]*)/; - var child = /(\[[^\[\]]*\])/g; + var brackets = /(\[[^[\]]*])/; + var child = /(\[[^[\]]*])/g; // Get the parent - var segment = parent.exec(key); + var segment = brackets.exec(key); + var parent = segment ? key.slice(0, segment.index) : key; // Stash the parent if it exists var keys = []; - if (segment[1]) { + if (parent) { // If we aren't using plain objects, optionally prefix keys // that would overwrite object prototype properties - if (!options.plainObjects && has.call(Object.prototype, segment[1])) { + if (!options.plainObjects && has.call(Object.prototype, parent)) { if (!options.allowPrototypes) { return; } } - keys.push(segment[1]); + keys.push(parent); } // Loop through children appending to the array until we hit depth @@ -145,9 +146,9 @@ var parseKeys = function parseKeys(givenKey, val, options) { var i = 0; while ((segment = child.exec(key)) !== null && i < options.depth) { i += 1; - if (!options.plainObjects && has.call(Object.prototype, segment[1].replace(/\[|\]/g, ''))) { + if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) { if (!options.allowPrototypes) { - continue; + return; } } keys.push(segment[1]); @@ -206,13 +207,13 @@ var utils = require('./utils'); var formats = require('./formats'); var arrayPrefixGenerators = { - brackets: function brackets(prefix) { + brackets: function brackets(prefix) { // eslint-disable-line func-name-matching return prefix + '[]'; }, - indices: function indices(prefix, key) { + indices: function indices(prefix, key) { // eslint-disable-line func-name-matching return prefix + '[' + key + ']'; }, - repeat: function repeat(prefix) { + repeat: function repeat(prefix) { // eslint-disable-line func-name-matching return prefix; } }; @@ -223,14 +224,28 @@ var defaults = { delimiter: '&', encode: true, encoder: utils.encode, - serializeDate: function serializeDate(date) { + encodeValuesOnly: false, + serializeDate: function serializeDate(date) { // eslint-disable-line func-name-matching return toISO.call(date); }, skipNulls: false, strictNullHandling: false }; -var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, formatter) { +var stringify = function stringify( // eslint-disable-line func-name-matching + object, + prefix, + generateArrayPrefix, + strictNullHandling, + skipNulls, + encoder, + filter, + sort, + allowDots, + serializeDate, + formatter, + encodeValuesOnly +) { var obj = object; if (typeof filter === 'function') { obj = filter(prefix, obj); @@ -238,7 +253,7 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu obj = serializeDate(obj); } else if (obj === null) { if (strictNullHandling) { - return encoder ? encoder(prefix) : prefix; + return encoder && !encodeValuesOnly ? encoder(prefix) : prefix; } obj = ''; @@ -246,7 +261,8 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) { if (encoder) { - return [formatter(encoder(prefix)) + '=' + formatter(encoder(obj))]; + var keyValue = encodeValuesOnly ? prefix : encoder(prefix); + return [formatter(keyValue) + '=' + formatter(encoder(obj))]; } return [formatter(prefix) + '=' + formatter(String(obj))]; } @@ -284,7 +300,8 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu sort, allowDots, serializeDate, - formatter + formatter, + encodeValuesOnly )); } else { values = values.concat(stringify( @@ -298,7 +315,8 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu sort, allowDots, serializeDate, - formatter + formatter, + encodeValuesOnly )); } } @@ -309,14 +327,20 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu module.exports = function (object, opts) { var obj = object; var options = opts || {}; + + if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') { + throw new TypeError('Encoder has to be a function.'); + } + var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter; var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls; var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode; - var encoder = encode ? (typeof options.encoder === 'function' ? options.encoder : defaults.encoder) : null; + var encoder = typeof options.encoder === 'function' ? options.encoder : defaults.encoder; var sort = typeof options.sort === 'function' ? options.sort : null; var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots; var serializeDate = typeof options.serializeDate === 'function' ? options.serializeDate : defaults.serializeDate; + var encodeValuesOnly = typeof options.encodeValuesOnly === 'boolean' ? options.encodeValuesOnly : defaults.encodeValuesOnly; if (typeof options.format === 'undefined') { options.format = formats.default; } else if (!Object.prototype.hasOwnProperty.call(formats.formatters, options.format)) { @@ -326,10 +350,6 @@ module.exports = function (object, opts) { var objKeys; var filter; - if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') { - throw new TypeError('Encoder has to be a function.'); - } - if (typeof options.filter === 'function') { filter = options.filter; obj = filter('', obj); @@ -376,12 +396,13 @@ module.exports = function (object, opts) { generateArrayPrefix, strictNullHandling, skipNulls, - encoder, + encode ? encoder : null, filter, sort, allowDots, serializeDate, - formatter + formatter, + encodeValuesOnly )); } @@ -422,7 +443,9 @@ exports.merge = function (target, source, options) { if (Array.isArray(target)) { target.push(source); } else if (typeof target === 'object') { - target[source] = true; + if (options.plainObjects || options.allowPrototypes || !has.call(Object.prototype, source)) { + target[source] = true; + } } else { return [target, source]; } @@ -517,7 +540,7 @@ exports.encode = function (str) { i += 1; c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); - out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]; + out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]; // eslint-disable-line max-len } return out; diff --git a/deps/npm/node_modules/request/node_modules/qs/lib/index.js b/deps/npm/node_modules/request/node_modules/qs/lib/index.js index 0d6a97dcf0..0d6a97dcf0 100755..100644 --- a/deps/npm/node_modules/request/node_modules/qs/lib/index.js +++ b/deps/npm/node_modules/request/node_modules/qs/lib/index.js diff --git a/deps/npm/node_modules/request/node_modules/qs/lib/parse.js b/deps/npm/node_modules/request/node_modules/qs/lib/parse.js index 97387a6a26..1307e9d797 100755..100644 --- a/deps/npm/node_modules/request/node_modules/qs/lib/parse.js +++ b/deps/npm/node_modules/request/node_modules/qs/lib/parse.js @@ -16,7 +16,7 @@ var defaults = { strictNullHandling: false }; -var parseValues = function parseValues(str, options) { +var parseValues = function parseQueryStringValues(str, options) { var obj = {}; var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit); @@ -42,7 +42,7 @@ var parseValues = function parseValues(str, options) { return obj; }; -var parseObject = function parseObject(chain, val, options) { +var parseObject = function parseObjectRecursive(chain, val, options) { if (!chain.length) { return val; } @@ -55,7 +55,7 @@ var parseObject = function parseObject(chain, val, options) { obj = obj.concat(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) && @@ -74,36 +74,37 @@ var parseObject = function parseObject(chain, val, options) { return obj; }; -var parseKeys = function parseKeys(givenKey, val, options) { +var parseKeys = function parseQueryStringKeys(givenKey, val, options) { if (!givenKey) { return; } // Transform dot notation to bracket notation - var key = options.allowDots ? givenKey.replace(/\.([^\.\[]+)/g, '[$1]') : givenKey; + var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey; // The regex chunks - var parent = /^([^\[\]]*)/; - var child = /(\[[^\[\]]*\])/g; + var brackets = /(\[[^[\]]*])/; + var child = /(\[[^[\]]*])/g; // Get the parent - var segment = parent.exec(key); + var segment = brackets.exec(key); + var parent = segment ? key.slice(0, segment.index) : key; // Stash the parent if it exists var keys = []; - if (segment[1]) { + if (parent) { // If we aren't using plain objects, optionally prefix keys // that would overwrite object prototype properties - if (!options.plainObjects && has.call(Object.prototype, segment[1])) { + if (!options.plainObjects && has.call(Object.prototype, parent)) { if (!options.allowPrototypes) { return; } } - keys.push(segment[1]); + keys.push(parent); } // Loop through children appending to the array until we hit depth @@ -111,9 +112,9 @@ var parseKeys = function parseKeys(givenKey, val, options) { var i = 0; while ((segment = child.exec(key)) !== null && i < options.depth) { i += 1; - if (!options.plainObjects && has.call(Object.prototype, segment[1].replace(/\[|\]/g, ''))) { + if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) { if (!options.allowPrototypes) { - continue; + return; } } keys.push(segment[1]); diff --git a/deps/npm/node_modules/request/node_modules/qs/lib/stringify.js b/deps/npm/node_modules/request/node_modules/qs/lib/stringify.js index 88cd791064..7694988c09 100755..100644 --- a/deps/npm/node_modules/request/node_modules/qs/lib/stringify.js +++ b/deps/npm/node_modules/request/node_modules/qs/lib/stringify.js @@ -4,13 +4,13 @@ var utils = require('./utils'); var formats = require('./formats'); var arrayPrefixGenerators = { - brackets: function brackets(prefix) { + brackets: function brackets(prefix) { // eslint-disable-line func-name-matching return prefix + '[]'; }, - indices: function indices(prefix, key) { + indices: function indices(prefix, key) { // eslint-disable-line func-name-matching return prefix + '[' + key + ']'; }, - repeat: function repeat(prefix) { + repeat: function repeat(prefix) { // eslint-disable-line func-name-matching return prefix; } }; @@ -21,14 +21,28 @@ var defaults = { delimiter: '&', encode: true, encoder: utils.encode, - serializeDate: function serializeDate(date) { + encodeValuesOnly: false, + serializeDate: function serializeDate(date) { // eslint-disable-line func-name-matching return toISO.call(date); }, skipNulls: false, strictNullHandling: false }; -var stringify = function stringify(object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter, sort, allowDots, serializeDate, formatter) { +var stringify = function stringify( // eslint-disable-line func-name-matching + object, + prefix, + generateArrayPrefix, + strictNullHandling, + skipNulls, + encoder, + filter, + sort, + allowDots, + serializeDate, + formatter, + encodeValuesOnly +) { var obj = object; if (typeof filter === 'function') { obj = filter(prefix, obj); @@ -36,7 +50,7 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu obj = serializeDate(obj); } else if (obj === null) { if (strictNullHandling) { - return encoder ? encoder(prefix) : prefix; + return encoder && !encodeValuesOnly ? encoder(prefix) : prefix; } obj = ''; @@ -44,7 +58,8 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean' || utils.isBuffer(obj)) { if (encoder) { - return [formatter(encoder(prefix)) + '=' + formatter(encoder(obj))]; + var keyValue = encodeValuesOnly ? prefix : encoder(prefix); + return [formatter(keyValue) + '=' + formatter(encoder(obj))]; } return [formatter(prefix) + '=' + formatter(String(obj))]; } @@ -82,7 +97,8 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu sort, allowDots, serializeDate, - formatter + formatter, + encodeValuesOnly )); } else { values = values.concat(stringify( @@ -96,7 +112,8 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu sort, allowDots, serializeDate, - formatter + formatter, + encodeValuesOnly )); } } @@ -107,14 +124,20 @@ var stringify = function stringify(object, prefix, generateArrayPrefix, strictNu module.exports = function (object, opts) { var obj = object; var options = opts || {}; + + if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') { + throw new TypeError('Encoder has to be a function.'); + } + var delimiter = typeof options.delimiter === 'undefined' ? defaults.delimiter : options.delimiter; var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : defaults.strictNullHandling; var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : defaults.skipNulls; var encode = typeof options.encode === 'boolean' ? options.encode : defaults.encode; - var encoder = encode ? (typeof options.encoder === 'function' ? options.encoder : defaults.encoder) : null; + var encoder = typeof options.encoder === 'function' ? options.encoder : defaults.encoder; var sort = typeof options.sort === 'function' ? options.sort : null; var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots; var serializeDate = typeof options.serializeDate === 'function' ? options.serializeDate : defaults.serializeDate; + var encodeValuesOnly = typeof options.encodeValuesOnly === 'boolean' ? options.encodeValuesOnly : defaults.encodeValuesOnly; if (typeof options.format === 'undefined') { options.format = formats.default; } else if (!Object.prototype.hasOwnProperty.call(formats.formatters, options.format)) { @@ -124,10 +147,6 @@ module.exports = function (object, opts) { var objKeys; var filter; - if (options.encoder !== null && options.encoder !== undefined && typeof options.encoder !== 'function') { - throw new TypeError('Encoder has to be a function.'); - } - if (typeof options.filter === 'function') { filter = options.filter; obj = filter('', obj); @@ -174,12 +193,13 @@ module.exports = function (object, opts) { generateArrayPrefix, strictNullHandling, skipNulls, - encoder, + encode ? encoder : null, filter, sort, allowDots, serializeDate, - formatter + formatter, + encodeValuesOnly )); } diff --git a/deps/npm/node_modules/request/node_modules/qs/lib/utils.js b/deps/npm/node_modules/request/node_modules/qs/lib/utils.js index 33c01c000d..b214332376 100755..100644 --- a/deps/npm/node_modules/request/node_modules/qs/lib/utils.js +++ b/deps/npm/node_modules/request/node_modules/qs/lib/utils.js @@ -31,7 +31,9 @@ exports.merge = function (target, source, options) { if (Array.isArray(target)) { target.push(source); } else if (typeof target === 'object') { - target[source] = true; + if (options.plainObjects || options.allowPrototypes || !has.call(Object.prototype, source)) { + target[source] = true; + } } else { return [target, source]; } @@ -126,7 +128,7 @@ exports.encode = function (str) { i += 1; c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); - out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]; + out += hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]; // eslint-disable-line max-len } return out; diff --git a/deps/npm/node_modules/request/node_modules/qs/package.json b/deps/npm/node_modules/request/node_modules/qs/package.json index c33dcd0b58..184e525e06 100644 --- a/deps/npm/node_modules/request/node_modules/qs/package.json +++ b/deps/npm/node_modules/request/node_modules/qs/package.json @@ -2,49 +2,49 @@ "_args": [ [ { - "raw": "qs@~6.3.0", + "raw": "qs@~6.4.0", "scope": null, "escapedName": "qs", "name": "qs", - "rawSpec": "~6.3.0", - "spec": ">=6.3.0 <6.4.0", + "rawSpec": "~6.4.0", + "spec": ">=6.4.0 <6.5.0", "type": "range" }, - "/Users/ogd/Documents/projects/npm/npm/node_modules/request" + "/Users/zkat/Documents/code/npm/node_modules/request" ] ], - "_from": "qs@>=6.3.0 <6.4.0", - "_id": "qs@6.3.0", + "_from": "qs@>=6.4.0 <6.5.0", + "_id": "qs@6.4.0", "_inCache": true, "_location": "/request/qs", - "_nodeVersion": "6.6.0", + "_nodeVersion": "7.7.1", "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/qs-6.3.0.tgz_1476663988179_0.7400497454218566" + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/qs-6.4.0.tgz_1488783808282_0.7979955193586648" }, "_npmUser": { "name": "ljharb", "email": "ljharb@gmail.com" }, - "_npmVersion": "3.10.3", + "_npmVersion": "4.1.2", "_phantomChildren": {}, "_requested": { - "raw": "qs@~6.3.0", + "raw": "qs@~6.4.0", "scope": null, "escapedName": "qs", "name": "qs", - "rawSpec": "~6.3.0", - "spec": ">=6.3.0 <6.4.0", + "rawSpec": "~6.4.0", + "spec": ">=6.4.0 <6.5.0", "type": "range" }, "_requiredBy": [ "/request" ], - "_resolved": "https://registry.npmjs.org/qs/-/qs-6.3.0.tgz", - "_shasum": "f403b264f23bc01228c74131b407f18d5ea5d442", + "_resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", + "_shasum": "13e26d28ad6b0ffaa91312cd3bf708ed351e7233", "_shrinkwrap": null, - "_spec": "qs@~6.3.0", - "_where": "/Users/ogd/Documents/projects/npm/npm/node_modules/request", + "_spec": "qs@~6.4.0", + "_where": "/Users/zkat/Documents/code/npm/node_modules/request", "bugs": { "url": "https://github.com/ljharb/qs/issues" }, @@ -58,27 +58,27 @@ "dependencies": {}, "description": "A querystring parser that supports nesting and arrays, with a depth limit", "devDependencies": { - "@ljharb/eslint-config": "^8.0.0", - "browserify": "^13.1.0", + "@ljharb/eslint-config": "^11.0.0", + "browserify": "^14.1.0", "covert": "^1.1.0", - "eslint": "^3.8.0", + "eslint": "^3.17.0", "evalmd": "^0.0.17", - "iconv-lite": "^0.4.13", + "iconv-lite": "^0.4.15", "mkdirp": "^0.5.1", "parallelshell": "^2.0.0", - "qs-iconv": "^1.0.3", + "qs-iconv": "^1.0.4", "safe-publish-latest": "^1.1.1", - "tape": "^4.6.2" + "tape": "^4.6.3" }, "directories": {}, "dist": { - "shasum": "f403b264f23bc01228c74131b407f18d5ea5d442", - "tarball": "https://registry.npmjs.org/qs/-/qs-6.3.0.tgz" + "shasum": "13e26d28ad6b0ffaa91312cd3bf708ed351e7233", + "tarball": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz" }, "engines": { "node": ">=0.6" }, - "gitHead": "8aa9c26f90335b5483a4f456dea9acbada8a881c", + "gitHead": "c7f87b8d2eedd377f6ace065655201f51bee6334", "homepage": "https://github.com/ljharb/qs", "keywords": [ "querystring", @@ -117,5 +117,5 @@ "test": "npm run --silent coverage", "tests-only": "node test" }, - "version": "6.3.0" + "version": "6.4.0" } diff --git a/deps/npm/node_modules/request/node_modules/qs/test/parse.js b/deps/npm/node_modules/request/node_modules/qs/test/parse.js index 3a9611ed99..e451e91fe3 100755..100644 --- a/deps/npm/node_modules/request/node_modules/qs/test/parse.js +++ b/deps/npm/node_modules/request/node_modules/qs/test/parse.js @@ -131,9 +131,9 @@ test('parse()', function (t) { st.deepEqual(qs.parse('foo[bad]=baz&foo[]=bar&foo[]=foo'), { foo: { bad: 'baz', 0: 'bar', 1: 'foo' } }); st.deepEqual(qs.parse('foo[0][a]=a&foo[0][b]=b&foo[1][a]=aa&foo[1][b]=bb'), { foo: [{ a: 'a', b: 'b' }, { a: 'aa', b: 'bb' }] }); - st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: false }), { a: { 0: 'b', c: true, t: 'u' } }); + st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: false }), { a: { 0: 'b', t: 'u' } }); st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: true }), { a: { 0: 'b', t: 'u', hasOwnProperty: 'c' } }); - st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: false }), { a: { 0: 'b', 1: 'c', x: 'y' } }); + st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: false }), { a: { 0: 'b', x: 'y' } }); st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: true }), { a: { 0: 'b', hasOwnProperty: 'c', x: 'y' } }); st.end(); }); @@ -152,8 +152,6 @@ test('parse()', function (t) { st.end(); }); - t.deepEqual(qs.parse('a[b]=c&a=d'), { a: { b: 'c', d: true } }, 'can add keys to objects'); - t.test('correctly prunes undefined values when converting an array to an object', function (st) { st.deepEqual(qs.parse('a[2]=b&a[99999999]=c'), { a: { 2: 'b', 99999999: 'c' } }); st.end(); @@ -413,9 +411,71 @@ test('parse()', function (t) { st.end(); }); + t.test('does not allow overwriting prototype properties', function (st) { + st.deepEqual(qs.parse('a[hasOwnProperty]=b', { allowPrototypes: false }), {}); + st.deepEqual(qs.parse('hasOwnProperty=b', { allowPrototypes: false }), {}); + + st.deepEqual( + qs.parse('toString', { allowPrototypes: false }), + {}, + 'bare "toString" results in {}' + ); + + st.end(); + }); + t.test('can allow overwriting prototype properties', function (st) { - st.deepEqual(qs.parse('a[hasOwnProperty]=b', { allowPrototypes: true }), { a: { hasOwnProperty: 'b' } }, { prototype: false }); - st.deepEqual(qs.parse('hasOwnProperty=b', { allowPrototypes: true }), { hasOwnProperty: 'b' }, { prototype: false }); + st.deepEqual(qs.parse('a[hasOwnProperty]=b', { allowPrototypes: true }), { a: { hasOwnProperty: 'b' } }); + st.deepEqual(qs.parse('hasOwnProperty=b', { allowPrototypes: true }), { hasOwnProperty: 'b' }); + + st.deepEqual( + qs.parse('toString', { allowPrototypes: true }), + { toString: '' }, + 'bare "toString" results in { toString: "" }' + ); + + st.end(); + }); + + t.test('params starting with a closing bracket', function (st) { + st.deepEqual(qs.parse(']=toString'), { ']': 'toString' }); + st.deepEqual(qs.parse(']]=toString'), { ']]': 'toString' }); + st.deepEqual(qs.parse(']hello]=toString'), { ']hello]': 'toString' }); + st.end(); + }); + + t.test('params starting with a starting bracket', function (st) { + st.deepEqual(qs.parse('[=toString'), { '[': 'toString' }); + st.deepEqual(qs.parse('[[=toString'), { '[[': 'toString' }); + st.deepEqual(qs.parse('[hello[=toString'), { '[hello[': 'toString' }); + st.end(); + }); + + t.test('add keys to objects', function (st) { + st.deepEqual( + qs.parse('a[b]=c&a=d'), + { a: { b: 'c', d: true } }, + 'can add keys to objects' + ); + + st.deepEqual( + qs.parse('a[b]=c&a=toString'), + { a: { b: 'c' } }, + 'can not overwrite prototype' + ); + + st.deepEqual( + qs.parse('a[b]=c&a=toString', { allowPrototypes: true }), + { a: { b: 'c', toString: true } }, + 'can overwrite prototype with allowPrototypes true' + ); + + st.deepEqual( + qs.parse('a[b]=c&a=toString', { plainObjects: true }), + { a: { b: 'c', toString: true } }, + 'can overwrite prototype with plainObjects true' + ); + st.end(); }); diff --git a/deps/npm/node_modules/request/node_modules/qs/test/stringify.js b/deps/npm/node_modules/request/node_modules/qs/test/stringify.js index 8818eaca84..711dae507d 100755..100644 --- a/deps/npm/node_modules/request/node_modules/qs/test/stringify.js +++ b/deps/npm/node_modules/request/node_modules/qs/test/stringify.js @@ -385,7 +385,7 @@ test('stringify()', function (t) { st.equal(prefix, '', 'prefix is empty'); st.equal(value, obj); } else if (prefix === 'c') { - return; + return void 0; } else if (value instanceof Date) { st.equal(prefix, 'e[f]'); return value.getTime(); @@ -535,4 +535,33 @@ test('stringify()', function (t) { ); st.end(); }); + + t.test('encodeValuesOnly', function (st) { + st.equal( + qs.stringify( + { a: 'b', c: ['d', 'e=f'], f: [['g'], ['h']] }, + { encodeValuesOnly: true } + ), + 'a=b&c[0]=d&c[1]=e%3Df&f[0][0]=g&f[1][0]=h' + ); + st.equal( + qs.stringify( + { a: 'b', c: ['d', 'e'], f: [['g'], ['h']] } + ), + 'a=b&c%5B0%5D=d&c%5B1%5D=e&f%5B0%5D%5B0%5D=g&f%5B1%5D%5B0%5D=h' + ); + st.end(); + }); + + t.test('encodeValuesOnly - strictNullHandling', function (st) { + st.equal( + qs.stringify( + { a: { b: null } }, + { encodeValuesOnly: true, strictNullHandling: true } + ), + 'a[b]' + ); + st.end(); + }); + }); diff --git a/deps/npm/node_modules/request/node_modules/qs/test/utils.js b/deps/npm/node_modules/request/node_modules/qs/test/utils.js index 0721dd8ec6..0721dd8ec6 100755..100644 --- a/deps/npm/node_modules/request/node_modules/qs/test/utils.js +++ b/deps/npm/node_modules/request/node_modules/qs/test/utils.js |