X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/9e77185fafaf4e60e2b73821e0e4b9b1a11fb85f..refs/tags/wordpress-4.1.1-scripts:/wp-includes/http.php diff --git a/wp-includes/http.php b/wp-includes/http.php index 3a5f4ada..02b653f5 100644 --- a/wp-includes/http.php +++ b/wp-includes/http.php @@ -4,7 +4,7 @@ * * Will eventually replace and standardize the WordPress HTTP requests made. * - * @link http://trac.wordpress.org/ticket/4779 HTTP API Proposal + * @link https://core.trac.wordpress.org/ticket/4779 HTTP API Proposal * * @package WordPress * @subpackage HTTP @@ -246,7 +246,7 @@ function wp_remote_retrieve_header( $response, $header ) { * @since 2.7.0 * * @param array $response HTTP response. - * @return string the response code. Empty string on incorrect parameter given. + * @return int|string The response code as an integer. Empty string on incorrect parameter given. */ function wp_remote_retrieve_response_code( $response ) { if ( is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response'])) @@ -381,8 +381,8 @@ function get_allowed_http_origins() { * * @since 3.4.0 * - * @param string Origin URL. If not provided, the value of get_http_origin() is used. - * @return bool True if the origin is allowed. False otherwise. + * @param null|string $origin Origin URL. If not provided, the value of get_http_origin() is used. + * @return bool|null True if the origin is allowed. False otherwise. */ function is_allowed_http_origin( $origin = null ) { $origin_arg = $origin; @@ -441,11 +441,13 @@ function send_origin_headers() { * * @since 3.5.2 * - * @return mixed URL or false on failure. + * @param string $url + * @return false|string URL or false on failure. */ function wp_http_validate_url( $url ) { + $original_url = $url; $url = wp_kses_bad_protocol( $url, array( 'http', 'https' ) ); - if ( ! $url ) + if ( ! $url || strtolower( $url ) !== strtolower( $original_url ) ) return false; $parsed_url = @parse_url( $url ); @@ -455,7 +457,7 @@ function wp_http_validate_url( $url ) { if ( isset( $parsed_url['user'] ) || isset( $parsed_url['pass'] ) ) return false; - if ( false !== strpos( $parsed_url['host'], ':' ) ) + if ( false !== strpbrk( $parsed_url['host'], ':#?[]' ) ) return false; $parsed_home = @parse_url( get_option( 'home' ) ); @@ -473,8 +475,7 @@ function wp_http_validate_url( $url ) { } if ( $ip ) { $parts = array_map( 'intval', explode( '.', $ip ) ); - if ( '127.0.0.1' === $ip - || ( 10 === $parts[0] ) + if ( 127 === $parts[0] || 10 === $parts[0] || ( 172 === $parts[0] && 16 <= $parts[1] && 31 >= $parts[1] ) || ( 192 === $parts[0] && 168 === $parts[1] ) ) {