From 509b845abc0d394c96779548d76c91432f7b9f0c Mon Sep 17 00:00:00 2001 From: dd32 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: http://core.svn.wordpress.org/trunk@21224 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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 9ff24384c..b3673041c 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;