Skip to content

Commit

Permalink
fix: throw if invalid content-type header (nodejs#1901)
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag authored and metcoder95 committed Jul 21, 2023
1 parent f2cf650 commit 2e45543
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/core/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ function processHeaderValue (key, val) {
} else if (headerCharRegex.exec(val) !== null) {
throw new InvalidArgumentError(`invalid ${key} header`)
}

return `${key}: ${val}\r\n`
}

Expand Down Expand Up @@ -313,11 +314,10 @@ function processHeader (request, key, val) {
} else if (
request.contentType === null &&
key.length === 12 &&
key.toLowerCase() === 'content-type' &&
headerCharRegex.exec(val) === null
key.toLowerCase() === 'content-type'
) {
request.contentType = val
request.headers += `${key}: ${val}\r\n`
request.headers += processHeaderValue(key, val)
} else if (
key.length === 17 &&
key.toLowerCase() === 'transfer-encoding'
Expand Down

0 comments on commit 2e45543

Please sign in to comment.