Skip to content
Permalink
Browse files

bug #22873 [HttpKernel] don't call getTrustedHeaderName() if possible…

… (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
  • Loading branch information...
nicolas-grekas committed May 25, 2017
2 parents 2642e72 + 6350dab commit 4e95aacc1770a65aa4c6e6bc05987d67f2d20666
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php
@@ -119,7 +119,11 @@ 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)) {
if (Request::HEADER_X_FORWARDED_FOR & Request::getTrustedHeaderSet()) {
$currentXForwardedFor = $request->headers->get('X_FORWARDED_FOR', '');
$server['HTTP_X_FORWARDED_FOR'] = ($currentXForwardedFor ? $currentXForwardedFor.', ' : '').$request->getClientIp();
} elseif (method_exists(Request::class, 'getTrustedHeaderName') && $trustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP, false)) {
$currentXForwardedFor = $request->headers->get($trustedHeaderName, '');
$server['HTTP_'.$trustedHeaderName] = ($currentXForwardedFor ? $currentXForwardedFor.', ' : '').$request->getClientIp();

0 comments on commit 4e95aac

Please sign in to comment.
You can’t perform that action at this time.