+[TC8.50b8]FTP:cd to folder name with " character

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
white
Power Member
Power Member
Posts: 5815
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

+[TC8.50b8]FTP:cd to folder name with " character

Post by *white »

When TC retrieves the path from the PWD response, TC does not handle "quote-doubling" (see here) if the path contains a double quote character.

Suppose a folder on the server named /folder/"quote containing some files.

Go to the folder named folder. The log file shows:

Code: Select all

CWD folder
250 Directory successfully changed.
PWD
257 "/folder"
Get directory
PORT ...
200 PORT command successful. Consider using PASV. 
LIST
150 Here comes the directory listing.
Download
Waiting for server...
226 Directory send OK.
Everything is OK so far.
Now go to the folder named "quote. The log file shows:

Code: Select all

CWD "quote
250 Directory successfully changed.
PWD
257 "/folder/""quote"
The directory on the server is changed OK.
TC gets the path /folder/ from 257 "/folder/""quote"
The folder /folder is already shown by TC, so TC does not retrieve the directory listing from server.

Press F2. The server log shows:

Code: Select all

Get directory
PORT ...
200 PORT command successful. Consider using PASV.
LIST
150 Here comes the directory listing.
Download
Waiting for server...
226 Directory send OK.
No TC has retrieved the contents of /folder/"quote while thinking this is the contents of /folder.

The breadcrumb bar has the same problem.

If the folder is named /folder/q"uote TC thinks the path is: /folder/q

Apparently TC simply retrieves the text between the first two double quote characters.
Server response: 257 "/folder/q""uote"
TC retrieves: /folder/q
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Sorry, I haven't seen this in any FTP connections so far. Quotes are not allowed in local file names anyway, so supporting this wouldn't be too useful.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5815
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

ghisler(Author) wrote:Sorry, I haven't seen this in any FTP connections so far. Quotes are not allowed in local file names anyway, so supporting this wouldn't be too useful.
Well, I can download the files from the folder without problems. TC only shows them in the wrong folder. Downloading files with quotes in the file name also works. TC asks the user for a new name.

If you download a folder containing a sub folder with a quote in the name, the sub folder is silently skipped. When the sub folder name contains other illegal characters (for the local file system) a prompt appears where the user can change the name. Only when the quote character is in the name, the sub folder is skipped without notifying the user. This is quite bad.


I also tried the sftp plugin.
Folders are displayed correctly.
Illegal characters in file names are automatically replaced by underscores.
Folders with any illegal characters are silently skipped when copied?????
Is this the same for all file system plugins?

The purpose of file system plugins (and of the FTP client) is to connect to other types of file systems. TC should be able to handle this.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

OK, I'm now allowing double quotes in paths in beta 9. However, I will not do anything about repeated quote characters. This seems to be a specific problem of your server. Pure-FTPd just returns
257 "/public_html/a/"folder" is your current location
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5815
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

HISTORY.TXT wrote:13.11.13 Fixed: FTP: Could not view/edit files in subdirs containing locally forbidden characters, e.g. a|b, when using new auto-re-upload method (32/64)
Wow, big change. It also effects copying from ftp server to local. Folders are no longer silently skipped. Forbidden characters in folder names are automatically translated to underscore characters.
ghisler(Author) wrote:However, I will not do anything about repeated quote characters. This seems to be a specific problem of your server.
As I mentioned the "quote-doubling" is mentioned in the official specification of the FTP protocol. I tested two different servers, one of them I know uses vsftpd. You can read here that FileZilla now also supports the "quote-doubling" and that ProFTPd also uses it.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

So what happens now when you try to access such a folder with beta 9? Are you able to do it? Or does it fail because the server expects just one quote instead of two?
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5815
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

ghisler(Author) wrote:So what happens now when you try to access such a folder with beta 9? Are you able to do it? Or does it fail because the server expects just one quote instead of two?
Most operations work OK because you get folder/file names from MLSD or LIST command and because you use relative paths for most operations. You use the PWD response to display the correct path in breadcrumb bar (often ftp folders are redirected). So only the path in breadcrumb bar is not correct and when I access this path in the breadcrumb bar I of course get an error:
logfile wrote:CWD /folder/""quote/
550 Failed to change directory.

HISTORY.TXT wrote:13.11.13 Fixed: FTP: Could not view/edit files in subdirs containing locally forbidden characters, e.g. a|b, when using new auto-re-upload method (32/64)
This also works now for the sftp plugin!
But folders with any illegal characters are still silently skipped when copied.
Suppose folder on server is: /folder/a|b
Copy /folder to local system -> a|b is not downloaded.
(the ftp client does handle this now)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

CWD /folder/""quote/
550 Failed to change directory.
Hmm, how does it look when you enter the directory directly? I guess that TC sends
CWD ""quote
which should give the same error?
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5815
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

ghisler(Author) wrote:Hmm, how does it look when you enter the directory directly? I guess that TC sends
CWD ""quote
No. As I said you get folder/file names from MLSD or LIST command. So:
logfile wrote:(get folder contents)
LIST
150 Here comes the directory listing.
Download
Waiting for server...
226 Directory send OK.
(user chooses to enter folder "quote)
CWD "quote
250 Directory successfully changed.
(check which folder we ended up in, show this in breadcrumb bar)
PWD
257 "/folder/""quote"
(get folder contents)
Get directory
...
So everything works OK. Even navigating using the breadcrumb bar beginning at the root. Only problem is when navigating using the breadcrumb bar starting at or behind a wrongly displayed folder.
FTP - File Transfer Protocol - Reference manual - by D J Bernstein wrote:Many servers fail to check for double quotes in the name prefix. There is no reliable way for the client to compensate for this.
Perhaps there is no reliable way to compensate, but I think you can go a long way.
I suggest to assume quote doubling. For servers not using quote doubling this would only be a problem for folder names containing two consecutive double quote characters. Furthermore, because you are always doing a CWD followed by a PWD you can compare the folder you use for the CWD command with the result you get from the PWD command.

consider FTP commands and responses:

Code: Select all

CWD folder
PWD
257 "path"
pseudo code:

Code: Select all

if folder contains quote 
{
  if path ends with /folder { stop assuming quote doubling from now on }
}
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Hmm, I don't think that it's worth to put too much efford in this - only a tiny fraction of people will have folder names with double quotes, a server which doubles them, and try to use the breadcrumb bar to enter it. It's no wonder that I never received a complaint for the last 20 years.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 5815
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

ghisler(Author) wrote:Hmm, I don't think that it's worth to put too much efford in this - only a tiny fraction of people will have folder names with double quotes, a server which doubles them, and try to use the breadcrumb bar to enter it.
1 The breadcrumb bar is there to be used, isn't it?
2 As mentioned several major server software use quote doubling. Pure-FTPd will probably follow sooner or later.
3 Even a smaller number of people will have folder names with two or more consecutive quote characters. It's a very small change to replace "" with ".
Post Reply