diff options
Diffstat (limited to 'deps/npm/node_modules/request/node_modules/qs/lib')
-rw-r--r--[-rwxr-xr-x] | deps/npm/node_modules/request/node_modules/qs/lib/index.js | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | deps/npm/node_modules/request/node_modules/qs/lib/parse.js | 27 | ||||
-rw-r--r--[-rwxr-xr-x] | deps/npm/node_modules/request/node_modules/qs/lib/stringify.js | 52 | ||||
-rw-r--r--[-rwxr-xr-x] | deps/npm/node_modules/request/node_modules/qs/lib/utils.js | 6 |
4 files changed, 54 insertions, 31 deletions
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; |