Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[HttpKernel] renamed path to _path to avoid collision
  • Loading branch information
fabpot committed Jan 23, 2013
commit e5135f67be3f8ecf69e02640fd89b714cc377eef
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public function onKernelRequest(GetResponseEvent $event)

$this->validateRequest($request);

parse_str($request->query->get('path', ''), $attributes);
parse_str($request->query->get('_path', ''), $attributes);
$request->attributes->add($attributes);
$request->attributes->set('_route_params', array_replace($request->attributes->get('_route_params', array()), $attributes));
$request->query->remove('path');
$request->query->remove('_path');
}

protected function validateRequest(Request $request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected function generateProxyUri(ControllerReference $reference, Request $req

$reference->attributes['_controller'] = $reference->controller;

$reference->query['path'] = http_build_query($reference->attributes, '', '&');
$reference->query['_path'] = http_build_query($reference->attributes, '', '&');

return $request->getUriForPath($this->proxyPath.'?'.http_build_query($reference->query, '', '&'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected function setUp()

public function testOnlyTriggeredOnProxyRoute()
{
$request = Request::create('http://example.com/foo?path=foo%3Dbar%26_controller%3Dfoo');
$request = Request::create('http://example.com/foo?_path=foo%3Dbar%26_controller%3Dfoo');

$listener = new RouterProxyListener(new UriSigner('foo'));
$event = $this->createGetResponseEvent($request);
Expand All @@ -38,7 +38,7 @@ public function testOnlyTriggeredOnProxyRoute()
$listener->onKernelRequest($event);

$this->assertEquals($expected, $request->attributes->all());
$this->assertTrue($request->query->has('path'));
$this->assertTrue($request->query->has('_path'));
}

/**
Expand Down Expand Up @@ -83,15 +83,15 @@ public function testAccessDeniedWithWrongSignature()
public function testWithSignature()
{
$signer = new UriSigner('foo');
$request = Request::create($signer->sign('http://example.com/_proxy?path=foo%3Dbar%26_controller%3Dfoo'), 'GET', array(), array(), array(), array('REMOTE_ADDR' => '10.0.0.1'));
$request = Request::create($signer->sign('http://example.com/_proxy?_path=foo%3Dbar%26_controller%3Dfoo'), 'GET', array(), array(), array(), array('REMOTE_ADDR' => '10.0.0.1'));

$listener = new RouterProxyListener($signer);
$event = $this->createGetResponseEvent($request);

$listener->onKernelRequest($event);

$this->assertEquals(array('foo' => 'bar', '_controller' => 'foo'), $request->attributes->get('_route_params'));
$this->assertFalse($request->query->has('path'));
$this->assertFalse($request->query->has('_path'));
}

private function createGetResponseEvent(Request $request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testRender()
$this->assertEquals('<esi:include src="/" />', $strategy->render('/', $request)->getContent());
$this->assertEquals("<esi:comment text=\"This is a comment\" />\n<esi:include src=\"/\" />", $strategy->render('/', $request, array('comment' => 'This is a comment'))->getContent());
$this->assertEquals('<esi:include src="/" alt="foo" />', $strategy->render('/', $request, array('alt' => 'foo'))->getContent());
$this->assertEquals('<esi:include src="http://localhost/_proxy?path=_format%3Dhtml%26_controller%3Dmain_controller" alt="http://localhost/_proxy?path=_format%3Dhtml%26_controller%3Dalt_controller" />', $strategy->render(new ControllerReference('main_controller', array(), array()), $request, array('alt' => new ControllerReference('alt_controller', array(), array())))->getContent());
$this->assertEquals('<esi:include src="http://localhost/_proxy?_path=_format%3Dhtml%26_controller%3Dmain_controller" alt="http://localhost/_proxy?_path=_format%3Dhtml%26_controller%3Dalt_controller" />', $strategy->render(new ControllerReference('main_controller', array(), array()), $request, array('alt' => new ControllerReference('alt_controller', array(), array())))->getContent());
}

private function getDefaultStrategy($called = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testRenderWithControllerAndSigner()
{
$strategy = new HIncludeRenderingStrategy(null, new UriSigner('foo'));

$this->assertEquals('<hx:include src="http://localhost/_proxy?path=_format%3Dhtml%26_controller%3Dmain_controller&_hash=hMh5ZalYRj5kWGIGawbIS93KFBE%3D"></hx:include>', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent());
$this->assertEquals('<hx:include src="http://localhost/_proxy?_path=_format%3Dhtml%26_controller%3Dmain_controller&_hash=ctQ5X4vzZnFmmPiqIqnBkVr%2B%2B10%3D"></hx:include>', $strategy->render(new ControllerReference('main_controller', array(), array()), Request::create('/'))->getContent());
}

public function testRenderWithUri()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public function testGenerateProxyUri($uri, $controller)
public function getGenerateProxyUriData()
{
return array(
array('http://localhost/_proxy?path=_format%3Dhtml%26_controller%3Dcontroller', new ControllerReference('controller', array(), array())),
array('http://localhost/_proxy?path=_format%3Dxml%26_controller%3Dcontroller', new ControllerReference('controller', array('_format' => 'xml'), array())),
array('http://localhost/_proxy?path=foo%3Dfoo%26_format%3Djson%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => 'foo', '_format' => 'json'), array())),
array('http://localhost/_proxy?bar=bar&path=foo%3Dfoo%26_format%3Dhtml%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => 'foo'), array('bar' => 'bar'))),
array('http://localhost/_proxy?foo=foo&path=_format%3Dhtml%26_controller%3Dcontroller', new ControllerReference('controller', array(), array('foo' => 'foo'))),
array('http://localhost/_proxy?_path=_format%3Dhtml%26_controller%3Dcontroller', new ControllerReference('controller', array(), array())),
array('http://localhost/_proxy?_path=_format%3Dxml%26_controller%3Dcontroller', new ControllerReference('controller', array('_format' => 'xml'), array())),
array('http://localhost/_proxy?_path=foo%3Dfoo%26_format%3Djson%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => 'foo', '_format' => 'json'), array())),
array('http://localhost/_proxy?bar=bar&_path=foo%3Dfoo%26_format%3Dhtml%26_controller%3Dcontroller', new ControllerReference('controller', array('foo' => 'foo'), array('bar' => 'bar'))),
array('http://localhost/_proxy?foo=foo&_path=_format%3Dhtml%26_controller%3Dcontroller', new ControllerReference('controller', array(), array('foo' => 'foo'))),
);
}

Expand All @@ -42,7 +42,7 @@ public function testGenerateProxyUriWithARequest()
$request->attributes->set('_format', 'json');
$controller = new ControllerReference('controller', array(), array());

$this->assertEquals('http://localhost/_proxy?path=_format%3Djson%26_controller%3Dcontroller', $this->getStrategy()->doGenerateProxyUri($controller, $request));
$this->assertEquals('http://localhost/_proxy?_path=_format%3Djson%26_controller%3Dcontroller', $this->getStrategy()->doGenerateProxyUri($controller, $request));
}

private function getStrategy()
Expand Down