-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] don't call getTrustedHeaderName() if possible #22873
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
[HttpKernel] don't call getTrustedHeaderName() if possible #22873
Conversation
xabbuh
commented
May 23, 2017
•
edited
Loading
edited
Q | A |
---|---|
Branch? | 3.3 |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | https://travis-ci.org/symfony/symfony/jobs/235008102 (failing tests of #22863) |
License | MIT |
Doc PR |
$currentXForwardedFor = $request->headers->get($trustedHeaderName, ''); | ||
|
||
$server['HTTP_'.$trustedHeaderName] = ($currentXForwardedFor ? $currentXForwardedFor.', ' : '').$request->getClientIp(); | ||
} elseif (Request::HEADER_X_FORWARDED_FOR & Request::getTrustedHeaderSet()) { |
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.
Actually, the non-deprecated API should be tried first, to use it when it is available IMO
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.
In fact, I think that we can just fix this in 3.3.
cd52a80
to
29c9d8c
Compare
29c9d8c
to
0ae049b
Compare
0ae049b
to
ccf2275
Compare
@@ -119,7 +119,13 @@ protected function createSubRequest($uri, Request $request) | |||
// Sub-request object will point to localhost as client ip and real client ip | |||
// will be included into trusted header for client ip | |||
try { | |||
if ($trustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP, false)) { | |||
$hasTrustedHeaderSet = method_exists(Request::class, 'getTrustedHeaderSet'); |
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.
I would avoid this check by bumping the min version of HttpFoundation in HttpKernel
7e0c424
to
b17d932
Compare
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.
👍
b17d932
to
6350dab
Compare
Thank you @xabbuh. |
… (xabbuh) This PR was merged into the 3.3 branch. Discussion ---------- [HttpKernel] don't call getTrustedHeaderName() if possible | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | https://travis-ci.org/symfony/symfony/jobs/235008102 (failing tests of #22863) | License | MIT | Doc PR | Commits ------- 6350dab don't call getTrustedHeaderName() if possible