Make WordPress Core

Changeset 25258


Ignore:
Timestamp:
09/05/2013 05:28:52 PM (11 years ago)
Author:
wonderboymusic
Message:

Avoids incorrect results when url_to_postid() checking is not strict enough. Adds a bunch of Unit Tests for `url_to_postid()', which is currently only tested lightly in some XML-RPC tests.

Props gcorne, gradyetc.
Fixes #20560.

Location:
trunk
Files:
1 added
1 edited

Legend:

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

    r24812 r25258  
    325325        $url = str_replace( $wp_rewrite->index . '/', '', $url );
    326326
    327     if ( false !== strpos($url, home_url()) ) {
    328         // Chop off http://domain.com
     327    if ( false !== strpos( trailingslashit( $url ), home_url( '/' ) ) ) {
     328        // Chop off http://domain.com/[path]
    329329        $url = str_replace(home_url(), '', $url);
    330330    } else {
    331331        // Chop off /path/to/blog
    332         $home_path = parse_url(home_url());
     332        $home_path = parse_url( home_url( '/' ) );
    333333        $home_path = isset( $home_path['path'] ) ? $home_path['path'] : '' ;
    334         $url = str_replace($home_path, '', $url);
     334        $url = preg_replace( sprintf( '#^%s#', preg_quote( $home_path ) ), '', trailingslashit( $url ) );
    335335    }
    336336
Note: See TracChangeset for help on using the changeset viewer.