Skip to content
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

Strict empty string content type checking in BodyParsingMiddleware::getMediaType #2958

Merged
merged 1 commit into from
May 6, 2020
Merged

Strict empty string content type checking in BodyParsingMiddleware::getMediaType #2958

merged 1 commit into from
May 6, 2020

Conversation

Ayesh
Copy link
Contributor

@Ayesh Ayesh commented May 6, 2020

\Slim\Middleware\BodyParsingMiddleware::getMediaType() method has a loose comparison operator, which can make the function return (string) 0 when the request content-type header has a value of (string) 0. This is because PHP considers 0 == ''.

While this is unhighlike unlikely that it will lead to a bug, because the body parsers need to be registered by the content-type header values, the === seems the accurate one to use to reduce this unexpected execution.

@coveralls
Copy link

coveralls commented May 6, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling 6f94beb on Ayesh:strict-comparison into 955dadf on slimphp:4.x.

@l0gicgate l0gicgate added this to the 4.6.0 milestone May 6, 2020
@l0gicgate l0gicgate merged commit b081ebd into slimphp:4.x May 6, 2020
@Ayesh Ayesh deleted the strict-comparison branch May 6, 2020 18:02
@l0gicgate l0gicgate mentioned this pull request Nov 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants