ArxOne / FTP

Simple FTP client
MIT License
37 stars 15 forks source link

Handling spaces in directory name. #26

Closed darrell-aevum closed 8 years ago

darrell-aevum commented 8 years ago

I'm trying to open a path on a FileZilla server that has spaces in it, but keep getting 550 error. Example ftpClient.ListEntries("/Test Folder") will be handled as "/Test\ Folder" on the server.

Is ArxOne.FTP changing the space character to "\ " or is FileZilla server doing that?

Thanks.

darrell-aevum commented 8 years ago

Also, FileZilla is the only server I've had this issue with. It works fine with other FTP Servers.

Thanks for the great library.

picrap commented 8 years ago

Hi Darell,

unfortunately, I couldn't find a way to handle special characters in FileZilla. This has always been a problem for me and I don't know how to solve it. As far as I remember, I've tried both to escape names and not escaping them, but could succeed. Have you tried the MlsdEntries function instead of ListEntries?

darrell-aevum commented 8 years ago

Thanks for the quick response.

I've tried the MlsdEntries, but got the same 550 error.

I will keep messing around with it and let you know if I find a solution.

Thanks again!

picrap commented 8 years ago

There is a class named FtpPlatform (there are also two inherited classes named WindowsFtpPlatform and UnixFtpPlatform. You can inherit from one of them to implement your own escaping (by overriding the EscapePath() method), so you can probably make some tests. However, as I already did some, I'm not optimistic.

darrell-aevum commented 8 years ago

The GetSystem(session) method on line 172 of FtpClient.cs returns "UNIX emulated by FileZilla".

If I override the UniexFtpPlatform EscapePath and remove the space from the escape characters, it works fine.

Is there a setting on the FileZilla server that I might be missing?

Thanks again!

picrap commented 8 years ago

I have a lot of problems with FileZilla and its specific behavior. However, since you found a way to circumvent the problem, I'll make a specific fix. Thanks for pointing this out, I'll let you know once an update is available.

darrell-aevum commented 8 years ago

I haven't tested any other special characters other than the space, but it seems that FileZilla, though emulating Unix, isn't escaping characters.

Again, I'm not sure if I am missing a setting in FileZilla or not.

Thanks for the quick action.

picrap commented 8 years ago

After testing, I can't make it work with spaces, with or without escaping them. Can you give me a sample?

darrell-aevum commented 8 years ago

Basically I added a UnixEmulatedFileZillaFtpPlatform.cs to the ArxOne.Ftp.Platform namespace with the following override: public override string EscapePath(string path) { return EscapePath(path, ""); }

Next I added UnixEmulatedFileZilla to the FtpServerType enum, then I added an "IF" statement to the GetServerType method to account for FileZilla: if (system.ToLower().Contains("filezilla")) _serverType = FtpServerType.UnixEmulatedFileZilla;

Finally I added a case to the GetFtpPlatform method in the FtpClient.cs file. case FtpServerType.UnixEmulatedFileZilla: return new UnixEmulatedFileZillaFtpPlatform();

Basically I made it account for a Unix Emulated File Zilla server and remove any escaping. I haven't had any issues with it.

I'm sure the "IF" statement could be refined.

Also, I'm not sure how differently my FileZilla server is setup from the norm.

Thanks, Darrell

picrap commented 8 years ago

I did exactly the same in a branch on the project; unfortunately, it still doesn't work for me :cry: I'll check the code and release it as a blind fix (I'll let you know here when it's released), you'll tell me if it's OK.

Darrio commented 8 years ago

Same problem with spaces in names(

picrap commented 8 years ago

Hi guys, this should be fixed in version 1.9.1. It was my mistake: FileZilla works fine without escaping but my test was failing because FileZilla does not support STAT commands (and both LIST and STAT were in the same test, which is a shame).

picrap commented 8 years ago

Note to @Darrio : the spaces in name bug was introduced because of FileZilla... And it is fixed in 1.9.2

darrell-aevum commented 8 years ago

Thanks again picrap! I will give it a shot in the morning.

darrell-aevum commented 7 years ago

Pricrap, On the WindowsFileZillaFtpPlatform, I still have to override the EscapePath method with

        public override string EscapePath(string path)
        {
            return EscapePath(path, "");
        }
darrell-aevum commented 7 years ago

Correction... The override is not necessary. I was having an issue connecting to the FTP Server in general.

picrap commented 7 years ago

So I guess this issue can stay closed? :)

darrell-aevum commented 7 years ago

Yes Sir, sorry about that.