WordPress.org

Make WordPress Core

Changeset 21224


Ignore:
Timestamp:
07/06/2012 01:54:15 PM (9 years ago)
Author:
dd32
Message:

Make get_home_path() work in more cases by being case insensitive and sanitzing Windows paths. In some cases (such as differing case of hostnames or paths in the site/home options, or when SCRIPT_FILENAME contains forward slashes) the function was failing to return the correct path, and would instead return /. Props to SergeyBiryukov for the initial patch. Fixes #20449 Fixes #10447

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/file.php

    r20313 r21224  
    8080    $home = get_option( 'home' );
    8181    $siteurl = get_option( 'siteurl' );
    82     if ( $home != '' && $home != $siteurl ) {
    83         $wp_path_rel_to_home = str_replace($home, '', $siteurl); /* $siteurl - $home */
    84         $pos = strrpos($_SERVER["SCRIPT_FILENAME"], $wp_path_rel_to_home);
    85         $home_path = substr($_SERVER["SCRIPT_FILENAME"], 0, $pos);
     82    if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) {
     83        $wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */
     84        $pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), $wp_path_rel_to_home);
     85        $home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos );
    8686        $home_path = trailingslashit( $home_path );
    8787    } else {
Note: See TracChangeset for help on using the changeset viewer.