ftp directory with spaces
Moderators: Hacker, petermad, Stefan2, white
ftp directory with spaces
I noticed a bug in how the TC CE ftp plugin handles spaces in a directory name.
When running the ftp plugin and changing to a directory with a space in it's name, TC does not list any of the files in the directory.
When running the ftp plugin and changing to a directory with a space in it's name, TC does not list any of the files in the directory.
- ghisler(Author)
- Site Admin
- Posts: 50390
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Unfortunately many FTP servers do not support listing directories with spaces in the name. The FTP plugin lists directories like this:
LIST /path/to/directory/name
I tried both
LIST /dir with space
and
LIST "/dir with space"
but it didn't work.
LIST /path/to/directory/name
I tried both
LIST /dir with space
and
LIST "/dir with space"
but it didn't work.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Using XP ftp
If I use a different client, such as the Windows XP ftp client, it will display all of the files in a directory with a space. TC CE does not.
- ghisler(Author)
- Site Admin
- Posts: 50390
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
TC for Windows works completely differently: It uses the CWD (change working directory) command to switch to the directory, and then send the LIST command. It seems that some servers support spaces in CWD but not in LIST. Unfortunately it's not possible to switch to this method because the FTP plugin has to use relative paths relative to the plugin root. Using the CWD command could cause redirections (links) or lead to directories which are even above the starting location...
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
The ftp protocol is the same for both the Windows XP ftp and TC CE ftp.ghisler(Author) wrote:TC for Windows works completely differently: It uses the CWD (change working directory) command to switch to the directory, and then send the LIST command.
I did a Wireshark capture of a Windows XP ftp session and it also issues the ftp CWD. PORT, and LIST ftp commands (without any ASCII quotes).
For my example the ftp commands to the server were:
CWD Cha File\r\n
PORT 10,10,10,10,19,142\r\n
LIST\r\n
- ghisler(Author)
- Site Admin
- Posts: 50390
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
No, it's not the same! TC CE uses the absolute path in the LIST command:
LIST /path
LIST /path
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
The protocol is defined in RFC 959 and RFC 3659ghisler(Author) wrote:No, it's not the same! TC CE uses the absolute path in the LIST command:
LIST /path
http://tools.ietf.org/html/rfc959
http://tools.ietf.org/html/rfc3659
I have never seen TC CE list the contents of the files in a directory when it has a space in it's name. There are plenty of examples of clients that do list the files.
I did a Airscanner Sniffer capture of TC CE ftp session. It showed the client:
PASV\r\n
LIST /pub/depot/Cha File/\r\n
Note that the Windows XP ftp client did:
LIST Cha File\r\n
- ghisler(Author)
- Site Admin
- Posts: 50390
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
I have already explained above why I can't use CWD:
Unfortunately it's not possible to switch to this method because the FTP plugin has to use relative paths relative to the plugin root. Using the CWD command could cause redirections (links) or lead to directories which are even above the starting location...
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
If you were to use the ftp CWD, wouldn't you just have to keep track (store) of the 2 absolute paths for reconstruction, namely:ghisler(Author) wrote:Unfortunately many FTP servers do not support listing directories with spaces in the name.
The absolute path to the ftp plugin-account and the ftp CWD path.
Then when referencing the ftp relative path, the absolute path could be reconstructed via:
/plugin/ftp/account/ftp-cwd
By using CWD, it appears that the listing of directories with spaces problem could be avoided.
- ghisler(Author)
- Site Admin
- Posts: 50390
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
The problem is with symbolic links, they can transfer you ANYWHERE, so PWD would return a completely different location...
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
- ghisler(Author)
- Site Admin
- Posts: 50390
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Not necessarily - for example, if the user goes down to a directory and then up (CWD .. or CDUP), the path could be something different from where the user came when he followed a symbolic link. Of course I could try to use CWD with full path, but this would probably have the same problems with spaces as using LIST with full path...
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
How about doing a PWD after any user directed CWD .. or CDUP, then replacing the user selected path with the PWD response.ghisler(Author) wrote:Not necessarily - for example, if the user goes down to a directory and then up (CWD .. or CDUP), the path could be something different from where the user came when he followed a symbolic link. Of course I could try to use CWD with full path, but this would probably have the same problems with spaces as using LIST with full path...
This way both the LIST directory space and the symbolic link problems would be averted.