Skip to content

Commit bf7ef39

Browse files
Merge branch '6.4' into 7.2
* 6.4: [WebProfilerBundle] Fix tests [Cache] Tests for Redis Replication with cache [BrowserKit] Fix submitting forms with empty file fields [WebProfilerBundle] Fix interception for non conventional redirects [DependencyInjection] Do not preload functions [DependencyInjection] Fix cloned lazy services not sharing their dependencies when dumped with PhpDumper [HttpClient] Fix activity tracking leading to negative timeout errors [Security] Return null instead of empty username to fix deprecation notice [DependencyInjection] Fix env default processor with scalar node
2 parents cd60cb3 + 069881b commit bf7ef39

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

EventListener/WebDebugToolbarListener.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function onKernelResponse(ResponseEvent $event): void
9999
return;
100100
}
101101

102-
if ($response->headers->has('X-Debug-Token') && $response->isRedirect() && $this->interceptRedirects && 'html' === $request->getRequestFormat()) {
102+
if ($response->headers->has('X-Debug-Token') && $response->isRedirect() && $this->interceptRedirects && 'html' === $request->getRequestFormat() && $response->headers->has('Location')) {
103103
if ($request->hasSession() && ($session = $request->getSession())->isStarted() && $session->getFlashBag() instanceof AutoExpireFlashBag) {
104104
// keep current flashes for one more request if using AutoExpireFlashBag
105105
$session->getFlashBag()->setAll($session->getFlashBag()->peekAll());

Tests/EventListener/WebDebugToolbarListenerTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public static function getInjectToolbarTests()
6363
public function testHtmlRedirectionIsIntercepted($statusCode)
6464
{
6565
$response = new Response('Some content', $statusCode);
66+
$response->headers->set('Location', 'https://example.com/');
6667
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
6768
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
6869

@@ -76,6 +77,7 @@ public function testHtmlRedirectionIsIntercepted($statusCode)
7677
public function testNonHtmlRedirectionIsNotIntercepted()
7778
{
7879
$response = new Response('Some content', '301');
80+
$response->headers->set('Location', 'https://example.com/');
7981
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
8082
$event = new ResponseEvent($this->createMock(Kernel::class), new Request([], [], ['_format' => 'json']), HttpKernelInterface::MAIN_REQUEST, $response);
8183

@@ -139,6 +141,7 @@ public function testToolbarIsNotInjectedOnContentDispositionAttachment()
139141
public function testToolbarIsNotInjectedOnRedirection($statusCode)
140142
{
141143
$response = new Response('<html><head></head><body></body></html>', $statusCode);
144+
$response->headers->set('Location', 'https://example.com/');
142145
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
143146
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
144147

0 commit comments

Comments
 (0)