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 | Owned by: | 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)
Change History (10)
#3
@
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
@
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.
#7
@
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.
Patch to add parsing of link details and normalization of the link name