-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] fixed using _method parameter with invalid type #28080
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
$request = new Request(); | ||
$request->setMethod('POST'); | ||
$request->query->set('_method', array('delete', 'patch')); | ||
$this->assertEquals('POST', $request->getMethod(), '->getMethod() returns the request method if invalid type is defined in query'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertSame()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xabbuh
Sorry, I just copied that from the assertion above to make no mistake. Thanks for the hint.
Should I fix this only for my new assertion or also for the others? Or should this be done in a different ticket?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing it just here is okay IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -1276,7 +1276,10 @@ public function getMethod() | |||
if ($method = $this->headers->get('X-HTTP-METHOD-OVERRIDE')) { | |||
$this->method = strtoupper($method); | |||
} elseif (self::$httpMethodParameterOverride) { | |||
$this->method = strtoupper($this->request->get('_method', $this->query->get('_method', 'POST'))); | |||
$method = $this->request->get('_method', $this->query->get('_method', 'POST')); | |||
if (\is_string($method)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what should happen when a non-string is found here?
returning it as is looks strange, isn't it? it break the method's signature somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case it would keep the current request method ("POST") because the override value is not valid. Sounds consistant to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, indeed :)
Thank you @Phobetor. |
…d type (Phobetor) This PR was squashed before being merged into the 2.8 branch (closes #28080). Discussion ---------- [HttpFoundation] fixed using _method parameter with invalid type | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #28079 | License | MIT | Doc PR | - This change makes sure that an incoming `_method` parameter is only used when it is a string value. Commits ------- 63583de [HttpFoundation] fixed using _method parameter with invalid type
This change makes sure that an incoming
_method
parameter is only used when it is a string value.