bug #22285 [HttpKernel] Fix forward compat with Request::setTrustedProxies() (nicolas-grekas)

This PR was merged into the 3.2 branch.

Discussion
----------

[HttpKernel] Fix forward compat with Request::setTrustedProxies()

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

Should make travis green again.

Commits
-------

6ecec35 [HttpKernel] Fix forward compat with Request::setTrustedProxies()
This commit is contained in:
Nicolas Grekas 2017-04-05 08:57:56 +02:00
commit db8231e6d0
5 changed files with 5 additions and 5 deletions

View File

@ -36,7 +36,7 @@ class WebProcessorTest extends TestCase
public function testUseRequestClientIp()
{
Request::setTrustedProxies(array('192.168.0.1'));
Request::setTrustedProxies(array('192.168.0.1'), -1);
list($event, $server) = $this->createRequestEvent(array('X_FORWARDED_FOR' => '192.168.0.2'));
$processor = new WebProcessor();

View File

@ -464,7 +464,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
// make sure HttpCache is a trusted proxy
if (!in_array('127.0.0.1', $trustedProxies = Request::getTrustedProxies())) {
$trustedProxies[] = '127.0.0.1';
Request::setTrustedProxies($trustedProxies);
Request::setTrustedProxies($trustedProxies, method_exists('Request', 'getTrustedHeaderSet') ? Request::getTrustedHeaderSet() : -1);
}
// always a "master" request (as the real master request can be in cache)

View File

@ -30,7 +30,7 @@ class ValidateRequestListenerTest extends TestCase
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
$request = new Request();
$request->setTrustedProxies(array('1.1.1.1'));
$request->setTrustedProxies(array('1.1.1.1'), -1);
$request->server->set('REMOTE_ADDR', '1.1.1.1');
$request->headers->set('FORWARDED', 'for=2.2.2.2');
$request->headers->set('X_FORWARDED_FOR', '3.3.3.3');

View File

@ -1218,7 +1218,7 @@ class HttpCacheTest extends HttpCacheTestCase
*/
public function testHttpCacheIsSetAsATrustedProxy(array $existing, array $expected)
{
Request::setTrustedProxies($existing);
Request::setTrustedProxies($existing, -1);
$this->setNextResponse();
$this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1'));

View File

@ -309,7 +309,7 @@ class HttpKernelTest extends TestCase
public function testInconsistentClientIpsOnMasterRequests()
{
$request = new Request();
$request->setTrustedProxies(array('1.1.1.1'));
$request->setTrustedProxies(array('1.1.1.1'), -1);
$request->server->set('REMOTE_ADDR', '1.1.1.1');
$request->headers->set('FORWARDED', 'for=2.2.2.2');
$request->headers->set('X_FORWARDED_FOR', '3.3.3.3');