Decide how invalid options are handled in the next major
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 28/100
- Issue type
- Refactor
- Clarity
- Needs clarification
- Activity status
- Active
- Tech stack
- express, javascript, node.js
- Domain
- backend
Research direction
Start by reading normalizeOptions and the json(), urlencoded(), and text() parser entry points to compare how each option is validated. Review the reported defaultCharset cases and the related change in #764. Done means a policy for invalid options has been selected, consistently implemented across parsers, and covered by tests, including case-insensitive charset handling.
Written by the indexing model from the issue text.
Description
@Phillip9587 suggested an issue for this in #764. Measured on master (02101da) with Node 26; the Express results use Express 5.3.0.
normalizeOptions, one option at a time:
| option | 42 |
false |
0 |
'' |
{} |
|---|---|---|---|---|---|
inflate |
true |
false |
true |
true |
true |
limit |
42 |
throws | 0 |
throws | throws |
verify |
throws | false |
false |
false |
throws |
defaultCharset |
42 |
'utf-8' |
'utf-8' |
'utf-8' |
{} |
type: 42 is accepted, and shouldParse() then returns false for an application/json request, so the parser quietly skips it.
defaultCharset across the parsers, for a request without a charset:
'UTF-8' |
42 or {} |
|
|---|---|---|
json() |
415 unsupported charset "UTF-8" |
each request throws TypeError: charset.slice is not a function (500 in Express) |
urlencoded() |
throws at construction | throws at construction |
text() |
200 | throws TypeError: encoding.toUpperCase is not a function inside the raw-body callback; Express cannot catch it and the process exits |
All three treat 0, false and '' as 'utf-8'.
So one option gets three policies: checked at construction in urlencoded(), per request in json(), and not at all in text(), where a non-string value ends the process on the first request.
The question for the next major is which policy all options follow: check types at construction and throw, as limit and verify partly do, or coerce. Either way, defaultCharset needs lower-casing before the utf-8/iso-8859-1 checks, which is what #764 does.
- Dominant language
- JavaScript
- Stars
- 5.5k
- Forks
- 802
- Avg merge
- 7h 54m
- Merged PRs (30d)
- 8
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from expressjs/body-parser
-
discuss ideas semver-major
Difficulty 3/5 1-2 days Newbie friendliness 55/100
expressjs/body-parser#780 · 1 comment ·
Maintainers usually reply within 1 day
-
deps semver-major
Difficulty 3/5 1-2 days Newbie friendliness 65/100
expressjs/body-parser#758 · 12 comments ·
Maintainers usually reply within 1 day
-
Almost all non-utf8 encodings are incorrectMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
expressjs/body-parser#680 · 4 comments ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
expressjs/body-parser#658 ·
Maintainers usually reply within 1 day
-
question
Difficulty 4/5 3-5 days Newbie friendliness 30/100
expressjs/body-parser#633 · 1 comment ·
Maintainers usually reply within 1 day
All issues in expressjs/body-parser
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
OWASP/CheatSheetSeries#3018 ·
Maintainers usually reply within 1 day
-
Radix number block generates NaN after switching a negative or decimal number to binary, octal or hexPossibly taken @matthewalberto claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
mit-cml/appinventor-sources#4246 · 1 comment ·
Maintainers usually reply within 1 day
-
marketing
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 83/100
GoogleChrome/modern-web-guidance-src#3675 · 2 comments ·
Maintainers usually reply within 1 day