-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
_format parameter handling enabled on default, potentially causing 500 errors #8966
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
Comments
I think the Request should use only the attribute to get the format instead of checking the query string and the posted values: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Request.php#L1287 |
@stof This is my idea as well. |
That's a tough one. I totally agree with the PR and limiting the |
It's also potentially problematic that the Here's a trivial example that forces HTML to be served as Perhaps Symfony should return a 406 error if there's no template for the given format, rather than serving a different template with the wrong |
…rely on the request attributes (pvandommelen) This PR was squashed before being merged into the 3.0-dev branch (closes #8967). Discussion ---------- [HttpFoundation] Request->getRequestFormat should only rely on the request attributes | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | possibly | Deprecations? | no | Tests pass? | yes | Fixed tickets | #8966 | License | MIT | Doc PR | Added test case and fix for #8966. Is this functionality relied on somewhere? Commits ------- 7115c1e [HttpFoundation] Request->getRequestFormat should only rely on the request attributes
…quest::get (Tobion) This PR was merged into the 3.0-dev branch. Discussion ---------- [HttpFoundation] change precedence of parameters in Request::get | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Allowing the request attributes to be overwritten via GET parameters is risky and made #8966 even worse. It is even more risky because it skips the requirements checks as configured in routing. So people that set requirements for routing placeholders like `\d+` or `html|json` can be sure it is validated when using the routing variables. But if developers use `$request->get()` to retrieve them, anybody from outside can set any value for those. Commits ------- e8d6764 [HttpFoundation] change precedence of parameters in Request::get
I think the handling of the _format get parameter is faulty. The handling of the parameter seems to be enabled on default, causing 500 errors when humans (or bots) append the
?_format=json
to any url of a symfony application.As I see it, the handling of the
_format
parameter should only be handled as I as a developer specify it.To reproduce:
When you run the following in a standard symfony-standard 2.3 checkout
/app_dev.php/hello/fieg?_format=json
You'll receive a 500 error page, this this error:
This is the case for every route in your application!
I asked some people on IRC (#symfony channel) about this and they agreed that this must be a bug.
The text was updated successfully, but these errors were encountered: