fix: Handle origin ports and enable lint-staged#97
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates REST origin validation to be port-aware (supporting local wp-env setups where sites run on different localhost ports) and enables lint-staged via Lefthook.
Changes:
- Include the origin port when building the request URL used for REST token lookup.
- Pass the origin port into same-site and governing-site host validation.
- Enable
lint-stagedas a pre-commit hook command.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
inc/Modules/Rest/Abstract_REST_Controller.php |
Makes REST permission checks and host comparisons aware of the Origin port. |
.lefthook.yml |
Enables lint-staged in the pre-commit hook. |
.github/PULL_REQUEST_TEMPLATE.md |
Simplifies and restructures the PR template sections. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $origin_port = $parsed_origin['port'] ?? 80; | ||
|
|
||
| if ( empty( $request_url ) || $this->is_url_from_host( get_site_url(), $parsed_origin['host'], $origin_port ) ) { |
There was a problem hiding this comment.
$origin_port defaults to 80 when the Origin header has no explicit port. For https origins this should default to 443 (and in general the default port should be derived from the parsed scheme). As-is, port-aware comparisons can incorrectly fail (or match) when one side includes an explicit default port (e.g., :443) and the other omits it. Consider deriving the default from $parsed_origin['scheme'] and also updating is_url_from_host() to use the parsed URL scheme when defaulting $url_port.
There was a problem hiding this comment.
Lets revert this file back. Not sure why onesearch isnt using the template from plugin-skeleton-d but it's really bad and doesn't make sense in a public-facing repo.
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
Description
Fix local REST origin validation so OneMedia
wp-envenvironments running on different localhost ports can communicate correctly.Technical Details
Checklist
wp-envenvironments.Screenshots
N/A
To-do
ci-artifactsprerelease.CODECOV_TOKEN.Fixes/Covers issue