8000 Merge branch '3.0' into 3.1 · symfony/symfony@e770e2e · GitHub
[go: up one dir, main page]

Skip to content

Commit e770e2e

Browse files
Merge branch '3.0' into 3.1
* 3.0: [FrameworkBundle] Fix fixtures [HttpKernel] Inline ValidateRequestListener logic into HttpKernel fixed HttpKernel dependencies after #18688 Conflicts: src/Symfony/Component/HttpKernel/HttpKernel.php src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php
2 parents 5128cd3 + b4fbcb3 commit e770e2e

18 files changed

+50
-141
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,5 @@
6161
<argument type="service" id="request_stack" />
6262
<tag name="kernel.event_subscriber" />
6363
</service>
64-
65-
<service id="validate_request_listener" class="Symfony\Component\HttpKernel\EventListener\ValidateRequestListener">
66-
<tag name="kernel.event_subscriber" />
67-
</service>
6864
</services>
6965
</container>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--------------------- -----------------------------------------------------------------
2-
Parameter Value
2+
 Parameter   Value 
33
--------------------- -----------------------------------------------------------------
44
twig.form.resources ["bootstrap_3_horizontal_layout.html.twig","bootstrap_3_layo...
55
--------------------- -----------------------------------------------------------------

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_public.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
=================================
44

55
------------------- --------------------------------------------------------
6-
Service ID Class name
6+
 Service ID   Class name 
77
------------------- --------------------------------------------------------
88
alias_1 alias for "service_1"
99
alias_2 alias for "service_2"

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_services.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
=============================================
44

55
------------------- --------------------------------------------------------
6-
Service ID Class name
6+
 Service ID   Class name 
77
------------------- --------------------------------------------------------
88
alias_1 alias for "service_1"
99
alias_2 alias for "service_2"

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/builder_1_tag1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
====================================================================
44

55
-------------- ------- ------- ------- -----------------------
6-
Service ID attr1 attr2 attr3 Class name
6+
 Service ID   attr1   attr2   attr3   Class name 
77
-------------- ------- ------- ------- -----------------------
88
definition_2 val1 val2 Full\Qualified\Class2
99
" val3

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
------------------ -----------------------------
2-
Option Value
2+
 Option   Value 
33
------------------ -----------------------------
44
Service ID -
55
Class Full\Qualified\Class1

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_2.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
------------------ -------------------------------------------------------
2-
Option Value
2+
 Option   Value 
33
------------------ -------------------------------------------------------
44
Service ID -
55
Class Full\Qualified\Class2

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_event1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
=======================================
44

55
------- ------------------- ----------
6-
Order Callable Priority
6+
 Order   Callable   Priority 
77
------- ------------------- ----------
88
#1 global_function() 255
99
#2 \Closure() -1

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/event_dispatcher_1_events.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
--------------
77

88
------- ------------------- ----------
9-
Order Callable Priority
9+
 Order   Callable   Priority 
1010
------- ------------------- ----------
1111
#1 global_function() 255
1212
#2 \Closure() -1
@@ -16,7 +16,7 @@
1616
--------------
1717

1818
------- ----------------------------------------------------------------------------------- ----------
19-
Order Callable Priority
19+
 Order   Callable   Priority 
2020
------- ----------------------------------------------------------------------------------- ----------
2121
#1 Symfony\Bundle\FrameworkBundle\Tests\Console\Descriptor\CallableClass::__invoke() 0
2222
------- ----------------------------------------------------------------------------------- ----------

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameter.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--------------- ---------
2-
Parameter Value
2+
 Parameter   Value 
33
--------------- ---------
44
database_name symfony
55
--------------- ---------

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/parameters_1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
============================
44

55
----------- --------------------------
6-
Parameter Value
6+
 Parameter   Value 
77
----------- --------------------------
88
array [12,"Hello world!",true]
99
boolean true

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/route_collection_1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--------- ---------- ------------ ----------- ---------------
2-
Name Method Scheme Host Path
2+
 Name   Method   Scheme   Host   Path 
33
--------- ---------- ------------ ----------- ---------------
44
route_1 GET|HEAD http|https localhost /hello/{name}
55
route_2 PUT|POST http|https localhost /name/add

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
},
4040
"require-dev": {
4141
"symfony/browser-kit": "~2.8|~3.0",
42-
"symfony/console": "~2.8|~3.0",
42+
"symfony/console": "~2.8.8|~3.0.8|~3.1.2|~3.2",
4343
"symfony/css-selector": "~2.8|~3.0",
4444
"symfony/dom-crawler": "~2.8|~3.0",
4545
"symfony/polyfill-intl-icu": "~1.0",

src/Symfony/Component/HttpKernel/EventListener/ValidateRequestListener.php

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/Symfony/Component/HttpKernel/HttpKernel.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
1616
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
1717
use Symfony\Component\HttpKernel\Event\FilterControllerArgumentsEvent;
18+
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
1819
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
1920
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
2021
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
@@ -24,6 +25,7 @@
2425
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
2526
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
2627
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
28+
use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException;
2729
use Symfony\Component\HttpFoundation\Request;
2830
use Symfony\Component\HttpFoundation\RequestStack;
2931
use Symfony\Component\HttpFoundation\Response;
@@ -117,6 +119,13 @@ public function terminateWithException(\Exception $exception)
117119
*/
118120
private function handleRaw(Request $request, $type = self::MASTER_REQUEST)
119121
{
122+
if (self::MASTER_REQUEST === $type && $request::getTrustedProxies()) {
123+
try {
124+
$request->getClientIps();
125+
} catch (ConflictingHeadersException $e) {
126+
throw new BadRequestHttpException('The request headers contain conflicting information regarding the origin of this request.', $e);
127+
}
128+
}
120129
$this->requestStack->push($request);
121130

122131
// request

src/Symfony/Component/HttpKernel/Tests/EventListener/ValidateRequestListenerTest.php

Lines changed: 0 additions & 67 deletions
This file was deleted.

src/Symfony/Component/HttpKernel/Tests/HttpKernelTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,33 @@ public function testVerifyRequestStackPushPopDuringHandle()
302302
$kernel->handle($request, HttpKernelInterface::MASTER_REQUEST);
303303
}
304304

305+
/**
306+
* @expectedException Symfony\Component\HttpKernel\Exception\BadRequestHttpException
307+
*/
308+
public function testInconsistentClientIpsOnMasterRequests()
309+
{
310+
$kernel = $this->getHttpKernel(new EventDispatcher());
311+
$request = new Request();
312+
$request->setTrustedProxies(array('1.1.1.1'));
313+
$request->server->set('REMOTE_ADDR', '1.1.1.1');
314+
$request->headers->set('FORWARDED', '2.2.2.2');
315+
$request->headers->set('X_FORWARDED_FOR', '3.3.3.3');
316+
317+
$kernel->handle($request, $kernel::MASTER_REQUEST, false);
318+
}
319+
320+
public function testInconsistentClientIpsOnSubRequests()
321+
{
322+
$kernel = $this->getHttpKernel(new EventDispatcher());
323+
$request = new Request();
324+
$request->setTrustedProxies(array('1.1.1.1'));
325+
$request->server->set('REMOTE_ADDR', '1.1.1.1');
326+
$request->headers->set('FORWARDED', '2.2.2.2');
327+
$request->headers->set('X_FORWARDED_FOR', '3.3.3.3');
328+
329+
$this->assertInstanceOf('Symfony\Component\HttpFoundation\Response', $kernel->handle($request, $kernel::SUB_REQUEST, false));
330+
}
331+
305332
private function getHttpKernel(EventDispatcherInterface $eventDispatcher, $controller = null, RequestStack $requestStack = null, array $arguments = array())
306333
{
307334
if (null === $controller) {

src/Symfony/Component/HttpKernel/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=5.5.9",
2020
"symfony/event-dispatcher": "~2.8|~3.0",
21-
"symfony/http-foundation": "~2.8|~3.0",
21+
"symfony/http-foundation": "~2.8.8|~3.0.8|~3.1.2|~3.2",
2222
"symfony/debug": "~2.8|~3.0",
2323
"psr/log": "~1.0"
2424
},

0 commit comments

Comments
 (0)
0