Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ftp] problem with folders with spaces #285

Open
shlykov opened this issue May 5, 2014 · 11 comments
Open

[ftp] problem with folders with spaces #285

shlykov opened this issue May 5, 2014 · 11 comments
Assignees
Labels

Comments

@shlykov
Copy link

shlykov commented May 5, 2014

ftp_rawlist() function returns empty result if there is a folder with space.
You can use ftp_nlist() which does not have this problem.

@stof
Copy link
Contributor

stof commented May 5, 2014

I think ftp_nlist could have the same issue, given that the PHP ftp_* functions don't escape their input.
I think the proper code would be to quote the directory name passed to ftp_rawlist

@shlykov
Copy link
Author

shlykov commented May 5, 2014

I tried to quote the directory name for ftp_rawlist, it did not work. but ftp_nlist works without the quotes. PHP 5.4.6

@staabm
Copy link
Contributor

staabm commented May 5, 2014

per php manual
http://de3.php.net/manual/en/function.ftp-nlist.php

 directory

    The directory to be listed. This parameter can also include arguments, eg. ftp_nlist($conn_id, "-la /your/dir"); Note that this parameter isn't escaped so there may be some issues with filenames containing spaces and other characters.

so ftp_list and ftp_rawlist should have the same problems (or the manual is wrong)

@staabm
Copy link
Contributor

staabm commented May 5, 2014

could you try sorrounding the path with single quotes?

@staabm
Copy link
Contributor

staabm commented May 5, 2014

per https://bugs.php.net/bug.php?id=15231 it could also help to escape the space with \

@shlykov
Copy link
Author

shlykov commented May 5, 2014

I looked into php source code there are no additional handlers for commands. I suspect it depends on the implementation of commands ftp server. As a result
ftp_nlist() solves my problem, but not solve the problem with spaces.

@Nek-
Copy link
Contributor

Nek- commented May 15, 2014

This lib looks great and probably fix the problem. We should maybe implement it. cc @l3l0

https://github.com/ngyuki/php-ftp-client

@Nek- Nek- added the bug label May 15, 2014
@stof
Copy link
Contributor

stof commented May 15, 2014

This library does not escape its argument either. So it suffers from the same issues than the PHP extension. the only difference is that it is written in PHP rather than C.
The FTP extension is enabled by default in PHP, so avoiding it for an alternative which is not better is a bad idea IMO

@PedroTroller PedroTroller added Fix and removed bug labels Nov 28, 2014
@andrejsstepanovs
Copy link

// looks like this works
ftp_chdir($conn, 'directory with spaces');
$files = ftp_nlist($conn, '');
$files = ftp_rawlist($conn, ''); // also working for me

-- from http://php.net/manual/en/function.ftp-nlist.php

@bhattbhaskar
Copy link

bhattbhaskar commented Jun 27, 2017

hi,
get a list of directories and files within the folder with space in a name. you can try with below code in PHP.

Working solution

ftp_chdir($conn, $path);
$children = ftp_rawlist($conn,'-a .');

@akerouanton
Copy link
Contributor

@php-dedicated-developers I'm unable to reproduce this bug with an up-to-date Gaufrette and vsftpd.

Could you provide more details please? For instance, what OS do you use on your FTP server, and on the server/computer running Gaufrette? Also, what FTP server do you use? Which version?...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests