-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Early filter invalid hosts in wp_http_validate_url() #10669
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
base: trunk
Are you sure you want to change the base?
Early filter invalid hosts in wp_http_validate_url() #10669
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
Thanks for the review! I’ve updated the patch to address all the points raised:
Please let me know if anything should be adjusted further. Appreciate you taking a look! |
|
Thanks for the feedback! I’ve updated the patch to address all the points:
Happy to adjust further if there’s anything else you’d like me to refine. |
|
@SirLouen what do you think? |
| ); | ||
|
|
||
| if ( | ||
| ! $is_ipv4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manhphuc I think you are shortcircuiting a little late
We have the $parse_url['host'] available much earlier.
Also, ipv4 will return a truthy value, so doing this won't be disruptive for such addresses
https://3v4l.org/Jau1h
I recommend you to debug a bit to set it in the best place. See what kind of values you are receiving earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion!
I’ve moved the IPv4 detection to right after normalizing $host, so it’s available earlier and reused in the ! $same_host branch. This keeps the behavior unchanged for IPv4 addresses, while avoiding the later short-circuit.
Let me know if you’d prefer it even earlier in the function.
Trac ticket: https://core.trac.wordpress.org/ticket/64457
Adds early hostname validation using the Filter extension when available, while falling back to the existing behavior when it’s not. Includes a test case for underscore hostnames.