Repository navigation
Unquote the host in the Forwarded header #8155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we are also stripping spaces when unquoting.
Are spaces also valid? I looked through rfc 7239 and I see the part about quotes but should something like
host= "test.com"be converted totest.com, or should it remaintest.com?And, if that is the case, then I suppose
host= test.comwithout quotes should also becometest.com? Or maybe not because it is implicitlyhost=" test.com "which means the spaces should be kept.The only mention of whitespace seems to be between identifiers which I think means between each
key=valueand not within thevalueitself but I am not 100% sure.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spaces around = or inside the value are not valid
rfc 7239 section 4 has forwarded-pair = token "=" value and value = token / quoted-string so there is no whitespace around = and a token cannot hold spaces so host= test.com is just invalid and not an implicit quoted string
the only whitespace it allows is the optional whitespace around commas from the list rule in rfc 7230 section 7 so host="example.com" , proto=https gives the value "example.com" with a trailing space which is why the outer \s* is there and why the value was already trimmed before this pr
inside quotes the spaces belong to the quoted string but section 5.3 says the unquoted host must match the host abnf which has no whitespace so host=" test.com " is not a valid host either
so all three of your examples are invalid and they all come out as test.com because i kept the existing trim the same as x-forwarded-host
happy to make it strict and only strip the quotes if you prefer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right I am dumb we were already doing
trim(), so this is not new behavior. My bad! I think this is good as it is. Thank you!