[WebProfilerBunde] Give an absolute url in case the request occured from another domain

This commit is contained in:
Romain Neutron 2016-04-16 12:08:57 +02:00
parent eb23f056f0
commit 1a5d4adadd
2 changed files with 5 additions and 4 deletions

View File

@ -65,7 +65,7 @@ class WebDebugToolbarListener implements EventSubscriberInterface
try {
$response->headers->set(
'X-Debug-Token-Link',
$this->urlGenerator->generate('_profiler', array('token' => $response->headers->get('X-Debug-Token')))
$this->urlGenerator->generate('_profiler', array('token' => $response->headers->get('X-Debug-Token')), UrlGeneratorInterface::ABSOLUTE_URL)
);
} catch (\Exception $e) {
$response->headers->set('X-Debug-Error', get_class($e).': '.$e->getMessage());

View File

@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class WebDebugToolbarListenerTest extends \PHPUnit_Framework_TestCase
{
@ -195,8 +196,8 @@ class WebDebugToolbarListenerTest extends \PHPUnit_Framework_TestCase
$urlGenerator
->expects($this->once())
->method('generate')
->with('_profiler', array('token' => 'xxxxxxxx'))
->will($this->returnValue('/_profiler/xxxxxxxx'))
->with('_profiler', array('token' => 'xxxxxxxx'), UrlGeneratorInterface::ABSOLUTE_URL)
->will($this->returnValue('http://mydomain.com/_profiler/xxxxxxxx'))
;
$event = new FilterResponseEvent($this->getKernelMock(), $this->getRequestMock(), HttpKernelInterface::MASTER_REQUEST, $response);
@ -204,7 +205,7 @@ class WebDebugToolbarListenerTest extends \PHPUnit_Framework_TestCase
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, 'bottom', $urlGenerator);
$listener->onKernelResponse($event);
$this->assertEquals('/_profiler/xxxxxxxx', $response->headers->get('X-Debug-Token-Link'));
$this->assertEquals('http://mydomain.com/_profiler/xxxxxxxx', $response->headers->get('X-Debug-Token-Link'));
}
public function testThrowingUrlGenerator()