From 21aefa4e4f3b62f3834294d9236f14a3225668ba Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Fri, 6 Jul 2012 13:54:15 +0000 Subject: [PATCH] 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 git-svn-id: https://develop.svn.wordpress.org/trunk@21224 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/file.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index 9ff24384cc..b3673041c5 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -79,10 +79,10 @@ function get_file_description( $file ) { function get_home_path() { $home = get_option( 'home' ); $siteurl = get_option( 'siteurl' ); - if ( $home != '' && $home != $siteurl ) { - $wp_path_rel_to_home = str_replace($home, '', $siteurl); /* $siteurl - $home */ - $pos = strrpos($_SERVER["SCRIPT_FILENAME"], $wp_path_rel_to_home); - $home_path = substr($_SERVER["SCRIPT_FILENAME"], 0, $pos); + if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) { + $wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */ + $pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), $wp_path_rel_to_home); + $home_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos ); $home_path = trailingslashit( $home_path ); } else { $home_path = ABSPATH;