From b47a1a46e57df9a529a9a0f5e7cf9f7b45c0c707 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Fri, 6 Jul 2012 11:39:39 +0000 Subject: [PATCH] WP_Filesystem: Return symlinked directory names correctly, previously the FTP extensions would return it as 'source -> dest' instead of simply 'source'. Props kurtpayne. Fixes #17846 git-svn-id: https://develop.svn.wordpress.org/trunk@21223 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/class-wp-filesystem-ftpext.php | 4 ++++ wp-admin/includes/class-wp-filesystem-ftpsockets.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php index 1228030472..d087189147 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -330,6 +330,10 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { } } + // Replace symlinks formatted as "source -> target" with just the source name + if ( $b['islink'] ) + $b['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $b['name'] ); + return $b; } diff --git a/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/wp-admin/includes/class-wp-filesystem-ftpsockets.php index 2e9fbd6997..1c931e1928 100644 --- a/wp-admin/includes/class-wp-filesystem-ftpsockets.php +++ b/wp-admin/includes/class-wp-filesystem-ftpsockets.php @@ -318,6 +318,10 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { $struc['files'] = array(); } + // Replace symlinks formatted as "source -> target" with just the source name + if ( $struc['islink'] ) + $struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] ); + $ret[ $struc['name'] ] = $struc; } return $ret;