-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[WebProfilerBundle] Fix intercept external redirects #52584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_redirect.html.twig
Outdated
Show resolved
Hide resolved
Maybe we could do this computation in the Controller directly ? Currently the code look like this (just formatted for clarity) WebProfilerBundle/EventListener/WebDebugToolbarListener.php $content = $this->twig->render('@WebProfiler/Profiler/toolbar_redirect.html.twig', [
'location' => $response->headers->get('Location'),
'host' => $request->getSchemeAndHttpHost()
]);
$response->setContent($content);
$response->setStatusCode(200);
$response->headers->remove('Location'); Something like this could do the job WDYT ? $content = $this->twig->render('@WebProfiler/Profiler/toolbar_redirect.html.twig', [
'location' => $location = $response->headers->get('Location'),
'absolute_location' => (new UrlHelper($requestStack))->getAbsoluteUrl($location),
]);
$response->setContent($content);
$response->setStatusCode(200);
$response->headers->remove('Location'); And that'd allow to keep in one place all those 'Location' manipulation / transformations. Because, even with the best intentions, i'm not sure the template code would be ever "obvious" (e g : WDYT ? |
I agree with @smnandre's proposal, the template can't contain this logic. |
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_redirect.html.twig
Outdated
Show resolved
Hide resolved
16a73a6
to
ce01d74
Compare
ce01d74
to
4ffadec
Compare
Thank you @HeahDude. |
When intercepting a redirect to an external host the current output gives:
With this PR, it fixes it too:
We could eventually get rid of the first part of the condition, WDYT?