diff --git a/src/wp-admin/includes/class-wp-filesystem-direct.php b/src/wp-admin/includes/class-wp-filesystem-direct.php index e8be5506d2..f201def08f 100644 --- a/src/wp-admin/includes/class-wp-filesystem-direct.php +++ b/src/wp-admin/includes/class-wp-filesystem-direct.php @@ -629,7 +629,8 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { return false; } - $ret = array(); + $path = trailingslashit( $path ); + $ret = array(); while ( false !== ( $entry = $dir->read() ) ) { $struc = array(); @@ -647,20 +648,20 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { continue; } - $struc['perms'] = $this->gethchmod( $path . '/' . $entry ); + $struc['perms'] = $this->gethchmod( $path . $entry ); $struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] ); $struc['number'] = false; - $struc['owner'] = $this->owner( $path . '/' . $entry ); - $struc['group'] = $this->group( $path . '/' . $entry ); - $struc['size'] = $this->size( $path . '/' . $entry ); - $struc['lastmodunix'] = $this->mtime( $path . '/' . $entry ); + $struc['owner'] = $this->owner( $path . $entry ); + $struc['group'] = $this->group( $path . $entry ); + $struc['size'] = $this->size( $path . $entry ); + $struc['lastmodunix'] = $this->mtime( $path . $entry ); $struc['lastmod'] = gmdate( 'M j', $struc['lastmodunix'] ); $struc['time'] = gmdate( 'h:i:s', $struc['lastmodunix'] ); - $struc['type'] = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f'; + $struc['type'] = $this->is_dir( $path . $entry ) ? 'd' : 'f'; if ( 'd' === $struc['type'] ) { if ( $recursive ) { - $struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive ); + $struc['files'] = $this->dirlist( $path . $struc['name'], $include_hidden, $recursive ); } else { $struc['files'] = array(); } diff --git a/src/wp-admin/includes/class-wp-filesystem-ftpext.php b/src/wp-admin/includes/class-wp-filesystem-ftpext.php index 8b59d0525e..975a4dd717 100644 --- a/src/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/src/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -761,12 +761,13 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { $dirlist[ $entry['name'] ] = $entry; } - $ret = array(); + $path = trailingslashit( $path ); + $ret = array(); foreach ( (array) $dirlist as $struc ) { if ( 'd' === $struc['type'] ) { if ( $recursive ) { - $struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive ); + $struc['files'] = $this->dirlist( $path . $struc['name'], $include_hidden, $recursive ); } else { $struc['files'] = array(); } diff --git a/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php index e64f47d44e..da771e4156 100644 --- a/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php +++ b/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php @@ -645,7 +645,8 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { return false; } - $ret = array(); + $path = trailingslashit( $path ); + $ret = array(); foreach ( $list as $struc ) { @@ -663,7 +664,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { if ( 'd' === $struc['type'] ) { if ( $recursive ) { - $struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive ); + $struc['files'] = $this->dirlist( $path . $struc['name'], $include_hidden, $recursive ); } else { $struc['files'] = array(); } diff --git a/src/wp-admin/includes/class-wp-filesystem-ssh2.php b/src/wp-admin/includes/class-wp-filesystem-ssh2.php index 351fbf6fb5..80fb81b971 100644 --- a/src/wp-admin/includes/class-wp-filesystem-ssh2.php +++ b/src/wp-admin/includes/class-wp-filesystem-ssh2.php @@ -774,6 +774,8 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { return false; } + $path = trailingslashit( $path ); + while ( false !== ( $entry = $dir->read() ) ) { $struc = array(); $struc['name'] = $entry; @@ -790,20 +792,20 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { continue; } - $struc['perms'] = $this->gethchmod( $path . '/' . $entry ); + $struc['perms'] = $this->gethchmod( $path . $entry ); $struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] ); $struc['number'] = false; - $struc['owner'] = $this->owner( $path . '/' . $entry ); - $struc['group'] = $this->group( $path . '/' . $entry ); - $struc['size'] = $this->size( $path . '/' . $entry ); - $struc['lastmodunix'] = $this->mtime( $path . '/' . $entry ); + $struc['owner'] = $this->owner( $path . $entry ); + $struc['group'] = $this->group( $path . $entry ); + $struc['size'] = $this->size( $path . $entry ); + $struc['lastmodunix'] = $this->mtime( $path . $entry ); $struc['lastmod'] = gmdate( 'M j', $struc['lastmodunix'] ); $struc['time'] = gmdate( 'h:i:s', $struc['lastmodunix'] ); - $struc['type'] = $this->is_dir( $path . '/' . $entry ) ? 'd' : 'f'; + $struc['type'] = $this->is_dir( $path . $entry ) ? 'd' : 'f'; if ( 'd' === $struc['type'] ) { if ( $recursive ) { - $struc['files'] = $this->dirlist( $path . '/' . $struc['name'], $include_hidden, $recursive ); + $struc['files'] = $this->dirlist( $path . $struc['name'], $include_hidden, $recursive ); } else { $struc['files'] = array(); }