From 6c6d746637f3014e3ad95c37ff033663a956ca91 Mon Sep 17 00:00:00 2001 From: dd32 Date: Fri, 6 Jul 2012 10:41:32 +0000 Subject: [PATCH] WP_Filesystem: Correct a rare case where the FTP directory will be detected incorrectly when the final path token exists higher in the chain, for example /x/x/Z/x/Z/ would be detected as /x/x/Z/. Fixes #20934 git-svn-id: http://core.svn.wordpress.org/trunk@21221 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-filesystem-base.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/class-wp-filesystem-base.php b/wp-admin/includes/class-wp-filesystem-base.php index 1f22f2418..5fd46396a 100644 --- a/wp-admin/includes/class-wp-filesystem-base.php +++ b/wp-admin/includes/class-wp-filesystem-base.php @@ -193,12 +193,13 @@ class WP_Filesystem_Base { $folder = untrailingslashit($folder); $folder_parts = explode('/', $folder); - $last_path = $folder_parts[ count($folder_parts) - 1 ]; + $last_index = array_pop( array_keys( $folder_parts ) ); + $last_path = $folder_parts[ $last_index ]; $files = $this->dirlist( $base ); - foreach ( $folder_parts as $key ) { - if ( $key == $last_path ) + foreach ( $folder_parts as $index => $key ) { + if ( $index == $last_index ) continue; //We want this to be caught by the next code block. //Working from /home/ to /user/ to /wordpress/ see if that file exists within the current folder,