You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
Currently, when setting intercept_redirects to true, the WDT will display a "Redirection intercepted!" page when it encounters a 201, 301, 302, 303, 307 or 308 along with a Location header.
The problem is that it doesn't filter the request format at this time, and as a consequence, WDT can even trigger an interception in an API context.
In a more concrete example, if you have the api-platform package installed and POST a new resource with Accept: application/json+ld, the application will return a 201 response with the freshly created resource Uri in the Location header.
But for the WebDebugToolbarListener, this is considered as a redirection and it should be intercepted.
Possible Solution
I suggest either adding 'html' === $request->getRequestFormat() as an additionnal condition for the interception to be triggered, or rely on $response->isRedirection() (>= 300, < 400) instead of $response->isRedirect() (201, 301, 302, 303, 307, 308):
…ormat (javiereguiluz)
This PR was merged into the 3.4 branch.
Discussion
----------
[WebProfilerBundle] Intercept redirections only for HTML format
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | #31168
| License | MIT
| Doc PR | -
This applies the solution proposed by @bpolaszek in #31168.
Commits
-------
4186788 Intercept redirections only for HTML format
Description
Currently, when setting
intercept_redirects
totrue
, the WDT will display a "Redirection intercepted!" page when it encounters a 201, 301, 302, 303, 307 or 308 along with aLocation
header.The problem is that it doesn't filter the request format at this time, and as a consequence, WDT can even trigger an interception in an API context.
In a more concrete example, if you have the
api-platform
package installed and POST a new resource withAccept: application/json+ld
, the application will return a 201 response with the freshly created resource Uri in theLocation
header.But for the
WebDebugToolbarListener
, this is considered as a redirection and it should be intercepted.Possible Solution
I suggest either adding
'html' === $request->getRequestFormat()
as an additionnal condition for the interception to be triggered, or rely on$response->isRedirection()
(>= 300, < 400) instead of$response->isRedirect()
(201, 301, 302, 303, 307, 308):symfony/src/Symfony/Bundle/WebProfilerBundle/EventListener/WebDebugToolbarListener.php
Line 90 in a59fe66
Thank you,
Ben
The text was updated successfully, but these errors were encountered: