fix: res.set('Content-Type') silently sets header to literal string#7111
Closed
JiwaniZakir wants to merge 1 commit intoexpressjs:masterfrom
Closed
fix: res.set('Content-Type') silently sets header to literal string#7111JiwaniZakir wants to merge 1 commit intoexpressjs:masterfrom
JiwaniZakir wants to merge 1 commit intoexpressjs:masterfrom
Conversation
Contributor
|
Duplicate of #7035 |
Contributor
This works even without this change and the issue (and my comment) explicitly mention that the problem occurs when the "type" does not contain a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7034
When
res.set('Content-Type', value)was called with an unrecognized MIME type,mime.contentType()returnedfalse, and thatfalsevalue was passed directly tothis.setHeader(), resulting in the literal string'false'being set as the Content-Type header. The fix inlib/response.jschanges the assignment inres.headertomime.contentType(value) || value, falling back to the original value whenmime.contentType()returns a falsy result. This preserves the existing behavior for recognized types while allowing unrecognized but valid Content-Type strings (e.g. custom or vendor types) to pass through unchanged. Verified against the reported reproduction case whereres.set('Content-Type', 'application/vnd.custom')previously set the header to'false'.