HTTP: Improve detection of valid IP addresses.

git-svn-id: https://develop.svn.wordpress.org/trunk@37115 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2016-03-30 15:37:26 +00:00
parent 14d4060c4e
commit 826b822214
1 changed files with 2 additions and 2 deletions

View File

@ -523,7 +523,7 @@ function wp_http_validate_url( $url ) {
$parsed_home = @parse_url( get_option( 'home' ) );
if ( isset( $parsed_home['host'] ) ) {
if ( isset( $parsed_home['host'] ) ) {
$same_host = ( strtolower( $parsed_home['host'] ) === strtolower( $parsed_url['host'] ) || 'localhost' === strtolower( $parsed_url['host'] ) );
} else {
$same_host = false;
@ -531,7 +531,7 @@ function wp_http_validate_url( $url ) {
if ( ! $same_host ) {
$host = trim( $parsed_url['host'], '.' );
if ( preg_match( '#^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$#', $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 ) ) {
$ip = $host;
} else {
$ip = gethostbyname( $host );