Skip to content

Commit

Permalink
Fix rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Phillip9587 committed Nov 19, 2024
1 parent 7814638 commit 07ab76b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/types/urlencoded.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ var genericParser = require('../..').generic

module.exports = urlencoded

/**
* Cache of parser modules.
*/

var parsers = Object.create(null)

/**
* Create a middleware to parse urlencoded bodies.
*
Expand Down Expand Up @@ -60,18 +66,17 @@ function urlencoded (options) {
* @param {object} options
*/

function createQueryParser (options, extended) {
function extendedparser (options) {
var parameterLimit = options.parameterLimit !== undefined
? options.parameterLimit
: 1000
var charsetSentinel = options.charsetSentinel
var interpretNumericEntities = options.interpretNumericEntities
var depth = extended ? (options.depth !== undefined ? options.depth : 32) : 0
var depth = (options.depth !== undefined ? options.depth : 32)

if (isNaN(parameterLimit) || parameterLimit < 1) {
throw new TypeError('option parameterLimit must be a positive number')
}

if (isNaN(depth) || depth < 0) {
throw new TypeError('option depth must be a zero or a positive number')
}
Expand All @@ -80,6 +85,8 @@ function createQueryParser (options, extended) {
parameterLimit = parameterLimit | 0
}

var parse = parser('qs')

return function queryparse (body, encoding) {
var paramCount = parameterCount(body, parameterLimit)

Expand All @@ -90,11 +97,11 @@ function createQueryParser (options, extended) {
})
}

var arrayLimit = extended ? Math.max(100, paramCount) : 0
var arrayLimit = Math.max(100, paramCount)

debug('parse ' + (extended ? 'extended ' : '') + 'urlencoding')
debug('parse extended urlencoding')
try {
return qs.parse(body, {
return parse(body, {
allowPrototypes: true,
arrayLimit: arrayLimit,
depth: depth,
Expand Down

0 comments on commit 07ab76b

Please sign in to comment.