-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] Dots are replaced by underscores in parameter names #9009
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
As documented in the stackoverflow answer, not only dots are converted into underscores but also some other chars. The code has no way to know which char was used originally (or if it was really mean to be an underscore). my suggestion is that you avoid using a dot in your GET and POST variables to avoid such issues |
The proposal on Gist does not use $_GET, $_POST, ... but use parse_str to retrieve query string. This function should be called with In my case, I don't really have a choice but to support dots in query string parameters so either I make this PR or I have to wait for #8957 one and override Request class even I'm really not a fan of this solution :( |
Looks like a duplicate of #6908 (at least, both are related) |
@fabpot: both have the same problem, ie. using This also has an impact when calling a Symfony API/website with non-PHP systems that don't use |
This is not duplicate of #6908, only related. The fix for this issue is to parse It seems this bug applies on |
Closing this one as this is just the way PHP parses HTTP requests and we won't workaround that. |
…oes the same as `parse_str()` but preserves dots in variable names (nicolas-grekas) This PR was merged into the 5.2-dev branch. Discussion ---------- [HttpFoundation] add `HeaderUtils::parseQuery()`: it does the same as `parse_str()` but preserves dots in variable names | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Inspired by symfony/psr-http-message-bridge#80 /cc @drupol Related to #9009, #29664, #26220 but also api-platform/core#509 and https://www.drupal.org/project/drupal/issues/2984272 /cc @dunglas @alexpott Commits ------- dd81e32 [HttpFoundation] add `HeaderUtils::parseQuery()`: it does the same as `parse_str()` but preserves dots in variable names
I didn't know but it seems that PHP is replacing dots by underscores in parameter names in all global variables ($_GET, $_POST, ...). This bug in PHP is described on stackoverflow and on php.net.
Since the Request class uses those globals in
createFromGlobals
method, all values in Request::$query, Request::$attributes, ... are "wrong".Is this a known and accepted behavior ? There is a Gist with a proposed solution. Do you think it is worth a PR or do I have to wait for @fabpot's one on RequestFactory (#8957) ?
The text was updated successfully, but these errors were encountered: