Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Merged
merged 1 commit into from
Jul 29, 2018
Merged

[HttpFoundation] fixed using _method parameter with invalid type #28080

merged 1 commit into from
Jul 29, 2018

Conversation

Phobetor
Copy link
Contributor

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.

$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');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertSame()

Copy link
Contributor Author

@Phobetor Phobetor Jul 27, 2018

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?

Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@nicolas-grekas nicolas-grekas added this to the 2.8 milestone Jul 28, 2018
@@ -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)) {
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, indeed :)

@nicolas-grekas
Copy link
Member

Thank you @Phobetor.

@nicolas-grekas nicolas-grekas merged commit 63583de into symfony:2.8 Jul 29, 2018
nicolas-grekas added a commit that referenced this pull request Jul 29, 2018
…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
@Phobetor Phobetor deleted the ticket_28079 branch October 27, 2021 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants