-
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?
Changes from 2 commits
b89bec6
1439d45
fc38d7a
6c7eccb
d8d86bd
aa5990c
fe877fd
0ad1fab
889fe26
897b851
9f70512
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -589,7 +589,23 @@ function wp_http_validate_url( $url ) { | |||||
| $host = trim( $parsed_url['host'], '.' ); | ||||||
|
|
||||||
| if ( ! $same_host ) { | ||||||
| if ( preg_match( '#^(([1-9]?\d|1\d\d|25[0-5]|2[0-4]\d)\.){3}([1-9]?\d|1\d\d|25[0-5]|2[0-4]\d)$#', $host ) ) { | ||||||
| $is_ipv4 = (bool) preg_match( | ||||||
| '#^(([1-9]?\d|1\d\d|25[0-5]|2[0-4]\d)\.){3}([1-9]?\d|1\d\d|25[0-5]|2[0-4]\d)$#', | ||||||
| $host | ||||||
| ); | ||||||
|
|
||||||
| if ( | ||||||
| ! $is_ipv4 | ||||||
|
||||||
| && function_exists( 'filter_var' ) | ||||||
westonruter marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| && ! filter_var( | ||||||
|
||||||
| && ! filter_var( | |
| && false === filter_var( |
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.
Good catch — updated to a strict false === filter_var() check to avoid loose negation and align with common core patterns. Thanks!
Uh oh!
There was an error while loading. Please reload this page.