diff --git a/HISTORY.md b/HISTORY.md index c9b0b5b9..e5c4fde6 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,9 @@ +1.20.5 / 2026-04-24 +=================== +* refactor(json): simplify strict mode error string construction +* fix: extended urlencoded parsing of arrays with >100 elements (#716) +* deps: qs@~6.15.1 + 1.20.4 / 2025-12-01 =================== diff --git a/lib/types/json.js b/lib/types/json.js index 59f3f7e2..d1f510d9 100644 --- a/lib/types/json.js +++ b/lib/types/json.js @@ -158,11 +158,7 @@ function createStrictSyntaxError (str, char) { var partial = '' if (index !== -1) { - partial = str.substring(0, index) + JSON_SYNTAX_CHAR - - for (var i = index + 1; i < str.length; i++) { - partial += JSON_SYNTAX_CHAR - } + partial = str.substring(0, index) + new Array(str.length - index + 1).join(JSON_SYNTAX_CHAR) } try { diff --git a/lib/types/urlencoded.js b/lib/types/urlencoded.js index 832992c2..892e3469 100644 --- a/lib/types/urlencoded.js +++ b/lib/types/urlencoded.js @@ -206,16 +206,15 @@ function getCharset (req) { function parameterCount (body, limit) { var count = 0 - var index = 0 + var index = -1 - while ((index = body.indexOf('&', index)) !== -1) { + do { count++ - index++ - - if (count === limit) { + if (count > limit) { return undefined } - } + index = body.indexOf('&', index + 1) + } while (index !== -1) return count } diff --git a/package.json b/package.json index c8e61c19..a1d16f88 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "body-parser", "description": "Node.js body parsing middleware", - "version": "1.20.4", + "version": "1.20.5", "contributors": [ "Douglas Christopher Wilson ", "Jonathan Ong (http://jongleberry.com)" @@ -17,7 +17,7 @@ "http-errors": "~2.0.1", "iconv-lite": "~0.4.24", "on-finished": "~2.4.1", - "qs": "~6.14.0", + "qs": "~6.15.1", "raw-body": "~2.5.3", "type-is": "~1.6.18", "unpipe": "~1.0.0"