Make WordPress Core

Opened 13 years ago

Closed 12 years ago

#17846 closed defect (bug) (fixed)

WP_Filesystem_FTPext::dirlist() doesn't handle symbolic links properly

Reported by: oded's profile Oded Owned by: dd32's profile dd32
Milestone: 3.5 Priority: normal
Severity: normal Version: 2.5
Component: Filesystem API Keywords: has-patch
Focuses: Cc:

Description

When listing files using WP_Filesystem_FTPext::dirlist() and encountering symbolic linux on a Unix FTP server, dirlist() returns the "file name" as a symbolic link textual description such as shown by "ls -l", e.g. "linkname -> /absolute/path/to/file".

It stands to reason as this is the expected format of the FTP LIST command, but users of dirlist() are getting a structure with full details and expect the value associated with the "name" key to contain only the name of the file (or the name of the link in this case).

WP_Filesystem_FTPext should parse links properly in parselisting() and hide the extraneous data so as not to confuse users of dirlist() that expect specific file names, when the expected file name is a symbolic link.

Attachments (2)

wp-filesystem-ftpext.patch (772 bytes) - added by Oded 13 years ago.
Patch to add parsing of link details and normalization of the link name
17846.patch (643 bytes) - added by kurtpayne 13 years ago.
Refreshed patch

Download all attachments as: .zip

Change History (10)

@Oded
13 years ago

Patch to add parsing of link details and normalization of the link name

#1 @SergeyBiryukov
13 years ago

  • Keywords has-patch added

@kurtpayne
13 years ago

Refreshed patch

#2 @kurtpayne
13 years ago

  • Cc kpayne@… added

Refreshed, condensed, and tested patch. Looks good.

#3 @Guss77
13 years ago

Thanks. Your patch looks fine. I wanted to do the test, under the assumption that there are operating systems where a link as output from the PHP ftp dir list may not look like that - but if you are sure, then I'm 100% behind that.

#4 @kurtpayne
13 years ago

I have tested this on Windows + FileZilla Server (wasn't able to create symlinks here) and CentOS + vsftpd (with symlinks of varied and complex names).

The WP_Filesystem_FTPext::dirlist() method uses ftp_rawlist() to get a file listing. There is no standard format for this listing, so WP can't be assured that symlinks will be represented in a -> b format. But the regex is targeted for that format and should skip over any new formats. It should be a safe fix.

#5 @kurtpayne
13 years ago

  • Version set to 2.5

#6 @dd32
12 years ago

  • Milestone changed from Awaiting Review to 3.5

#7 @dd32
12 years ago

The Direct method doesn't appear to be affected, Both the PHP Extension and the FTP Sockets classes were affected.

I can't test the SSH2 extension - but it generally works somewhere in between both, but it's life is limited (Although i've been saying that for over a year: #16925 & http://wordpress.org/extend/plugins/ssh-sftp-updater-support/ ).

I've tested kurtpayne's patch, and it appears to work as expected.

#8 @dd32
12 years ago

  • Owner set to dd32
  • Resolution set to fixed
  • Status changed from new to closed

In [21223]:

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

Note: See TracTickets for help on using tickets.