WordPress.org

Make WordPress Core

Changeset 29850


Ignore:
Timestamp:
10/08/2014 05:37:56 AM (5 years ago)
Author:
dd32
Message:

Correctly handle url's containing url's in WP_HTTP::make_absolute_url().
A valid relative URL could be mistaken for an absolute url if it contained a : in any position of the url.
Fixes #28001

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-http.php

    r29849 r29850  
    676676            return $maybe_relative_path;
    677677
    678         // Check for a scheme.
    679         if ( false !== strpos( $maybe_relative_path, '://' ) )
    680             return $maybe_relative_path;
    681 
    682678        if ( ! $url_parts = @parse_url( $url ) )
    683679            return $maybe_relative_path;
     
    685681        if ( ! $relative_url_parts = @parse_url( $maybe_relative_path ) )
    686682            return $maybe_relative_path;
     683
     684        // Check for a scheme on the 'relative' url
     685        if ( ! empty( $relative_url_parts['scheme'] ) ) {
     686            return $maybe_relative_path;
     687        }
    687688
    688689        $absolute_path = $url_parts['scheme'] . '://' . $url_parts['host'];
  • trunk/tests/phpunit/tests/http/http.php

    r25002 r29850  
    5757
    5858            // A file with a leading dot
    59             array( '.ext', 'http://example.com/', 'http://example.com/.ext' )
     59            array( '.ext', 'http://example.com/', 'http://example.com/.ext' ),
     60
     61            // URls within URLs
     62            array( '/expected', 'http://example.com/sub/http://site.com/sub/', 'http://example.com/expected' ),
     63            array( '/expected/http://site.com/sub/', 'http://example.com/', 'http://example.com/expected/http://site.com/sub/' ),
    6064        );
    6165    }
Note: See TracChangeset for help on using the changeset viewer.