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

Fix REST request validation by directly checking $_SERVER vars #137

Closed
wants to merge 3 commits into from
Closed

Fix REST request validation by directly checking $_SERVER vars #137

wants to merge 3 commits into from

Conversation

ot-st
Copy link

@ot-st ot-st commented Apr 5, 2024

Related tickets & documents

None

Description

This pull request addresses a critical flaw in the validate_request method where it incorrectly assumed the state of a newly instantiated WP_REST_Request object without parameters. Originally, the method attempted to validate the request method and content type using this uninitialized object, leading to a logical mistake where the validation could never properly execute due to the absence of correctly set values within the WP_REST_Request object.

Key Changes:

  • Removed the creation and use of an empty WP_REST_Request object for method and content type checks.
  • Implemented direct validation against the $_SERVER global for 'REQUEST_METHOD' and 'CONTENT_TYPE'.
  • Simplified the method's logic, improving readability and maintainability.

ot-st and others added 3 commits April 5, 2024 12:01
Line 75, `$request = new WP_REST_Request();` creates a new WP_Rest_Request without parameters and so it's effectively empty, but then the rest of the function behaves as if it wasn't empty leading to a situation where you can't delete a card.
Resolved specific problems in request validation logic that were
identified by automated checks, including ensuring the HTTP request
method is properly checked and content type validation is case-insensitive.
@ot-st ot-st closed this by deleting the head repository Apr 24, 2024
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.

1 participant