Uh oh!
There was an error while loading. Please reload this page.
Fixed: res.format crashing when only default option is provided - #2665
Closed
behcet wants to merge 2 commits into
Closed
Fixed: res.format crashing when only default option is provided#2665behcet wants to merge 2 commits into
behcet wants to merge 2 commits into
Conversation
dougwilson
commented
May 29, 2015
Contributor
Great find! |
Contributor
There was a problem hiding this comment.
Just skip calling req.accepts when keys.length === 0
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 freeto 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.
res.formatcrashes when provided only the default parameter.Code:
Stack:
curl request
curl -H 'Content-Type: application/json' -H 'Accept: application/json' -v htt p://127.0.0.1:5555/After brief debugging response.js > res.format function I found that
req.accepts()short circuits when!keys.length(which is zero, since we deleted obj.default) and returns internal functionthis.negotiator.mediaTypes(), which is in array type. Then it callsmime.lookup(type)on utils.js > exports.normalizeType with the array which we previously got fromreq.accepts, and crashes.