Fix listing URL validation without explicit schemes - #2943
Open
RabbiIslamRony wants to merge 1 commit into
Open
Conversation
Normalize submitted URL values to HTTP or HTTPS before validation so entries such as www.example.com pass without requiring a DNS lookup. Validate URL syntax locally and reject embedded user credentials to prevent deceptive links while continuing to block unsupported protocols.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
What kind of change does this PR introduce?
Description
Listing website fields were validated with
wp_http_validate_url(), which is intended for outbound HTTP request safety and performs a DNS lookup. As a result, a syntactically valid URL could returnInvalid URLwhen the domain could not be resolved during submission. This was especially confusing when users entered common scheme-less values such aswww.example.com.This change:
esc_url_raw()with an explicit HTTP/HTTPS allowlist;How to reproduce the issue or how to test the changes:
www.example.com.http://www.example.com.ftp://example.comare rejected.https://trusted.example@evil.exampleare rejected.Validation performed:
php -l includes/fields/class-directorist-url-field.phpgit diff --check -- includes/fields/class-directorist-url-field.phpBefore
https://prnt.sc/m4zOLpPuKrjE
After
https://www.loom.com/share/b2ac8de247ce4c42a57722b70f286d60
Any linked issues
Fixes #
Checklist