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

[HttpFoundation] Fix Request::getHost() when having several hosts in X_FORWARDED_HOST #21846

Merged
merged 1 commit into from Mar 22, 2017

Conversation

Projects
None yet
3 participants
@nicolas-grekas
Member

nicolas-grekas commented Mar 3, 2017

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

The first "host" in the list provided by X_FORWARDED_HOST should be the one, not the last.
Already the case for "port" and "scheme".

$host = $elements[count($elements) - 1];
$host = $elements[0];

This comment has been minimized.

@fabpot

fabpot Mar 3, 2017

Member

That's suspicious to me. Why do you think this is a bug?

@fabpot

fabpot Mar 3, 2017

Member

That's suspicious to me. Why do you think this is a bug?

This comment has been minimized.

@nicolas-grekas

nicolas-grekas Mar 3, 2017

Member

Because the port and scheme info are taken from the other edge, so this looks even more suspicious to me :) if the goal is to give back the user facing host, this is currently the wrong side.
I'd be happy to have eg @stof give his PV here.

@nicolas-grekas

nicolas-grekas Mar 3, 2017

Member

Because the port and scheme info are taken from the other edge, so this looks even more suspicious to me :) if the goal is to give back the user facing host, this is currently the wrong side.
I'd be happy to have eg @stof give his PV here.

@fabpot

This comment has been minimized.

Show comment
Hide comment
@fabpot

fabpot Mar 22, 2017

Member

Thank you @nicolas-grekas.

Member

fabpot commented Mar 22, 2017

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 9a2b2de into symfony:2.7 Mar 22, 2017

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
fabbot.io Your code looks good.
Details

fabpot added a commit that referenced this pull request Mar 22, 2017

bug #21846 [HttpFoundation] Fix Request::getHost() when having severa…
…l hosts in X_FORWARDED_HOST (nicolas-grekas)

This PR was merged into the 2.7 branch.

Discussion
----------

[HttpFoundation] Fix Request::getHost() when having several hosts in X_FORWARDED_HOST

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

The first "host" in the list provided by `X_FORWARDED_HOST` should be the one, not the last.
Already the case for "port" and "scheme".

Commits
-------

9a2b2de [HttpFoundation] Fix Request::getHost() when having several hosts in X_FORWARDED_HOST

@nicolas-grekas nicolas-grekas deleted the nicolas-grekas:req-fix branch Mar 22, 2017

This was referenced Apr 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment