Make WordPress Core

Changeset 30445


Ignore:
Timestamp:
11/20/2014 02:01:19 PM (10 years ago)
Author:
nacin
Message:

Better validation of the URL used in core HTTP requests.

Merges [30443] to the 3.9 branch.

Location:
branches/3.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.9

  • branches/3.9/src/wp-includes/http.php

    r27953 r30445  
    452452 */
    453453function wp_http_validate_url( $url ) {
     454    $original_url = $url;
    454455    $url = wp_kses_bad_protocol( $url, array( 'http', 'https' ) );
    455     if ( ! $url )
     456    if ( ! $url || strtolower( $url ) !== strtolower( $original_url ) )
    456457        return false;
    457458
     
    463464        return false;
    464465
    465     if ( false !== strpos( $parsed_url['host'], ':' ) )
     466    if ( false !== strpbrk( $parsed_url['host'], ':#?[]' ) )
    466467        return false;
    467468
     
    481482        if ( $ip ) {
    482483            $parts = array_map( 'intval', explode( '.', $ip ) );
    483             if ( '127.0.0.1' === $ip
    484                 || ( 10 === $parts[0] )
     484            if ( 127 === $parts[0] || 10 === $parts[0]
    485485                || ( 172 === $parts[0] && 16 <= $parts[1] && 31 >= $parts[1] )
    486486                || ( 192 === $parts[0] && 168 === $parts[1] )
Note: See TracChangeset for help on using the changeset viewer.