Support This Project

Ticket #82 (new defect)

Opened 2 years ago

Last modified 1 year ago

extended ascii characters in filenames not working with windows

Reported by: virdiq Assigned to: anonymous
Priority: major Milestone: 0.9.0
Component: server core Version: 0.8.1
Severity: major Keywords: CONFIRMED
Cc:

Description

Tested with SVN build 1626 based on a bug report by DeathWolf here on the forums.

I am compiling under Visual Studio 8 (2005) on Windows XP SP2. CMAKE flags enabled: WITH_IPV6, WITH_OpenSSL, WITH_UTF8.

Making directories with high ASCII characters in the folder name will not work:

MKD öooo
553 Requested action not taken: dirname does not match pathfilter

If a file called öooo already exists then the directory listing will show öooo instead.

Attempting to RETR the öooo file results in:

RETR öooo.txt
501 Invalid file name

DELE also does not work with high ASCII characters, returning:

DELE öooo.txt
501 Permission denied or inexistant file

Change History

03/06/07 14:00:36 changed by virdiq

  • keywords set to CONFIRMED.

I'm stumped with this one. It seems like something to do with Unicode conversion or some other character conversion, but I could be wrong. I couldn't find any specific code that filters out "bad ASCII characters" as such...?

Help required! :)

03/06/07 14:16:16 changed by pollux

  • milestone set to 0.8.2.

03/07/07 04:59:08 changed by virdiq

  • priority changed from minor to major.
  • version set to 0.8.1.
  • severity changed from minor to major.

04/10/07 14:35:49 changed by virdiq

The DELE command is failing at line 1690 in wzd_file.c (SVN 1656) due to:

  ret = unlink(filename);
  if (ret==-1) {

The value of filename in my test was: C:/wzdftpd-dbg/ftproot/öooo.txt" (const char *)

unlink() is returning -1 when called with non-ASCII values in the filename.

errno is being set to ENOENT (0x2) which means the file or path is not found or the path specified a directory.

04/10/07 14:38:37 changed by virdiq

Note that my last message is wrong... the problem is not with unlink() but rather with the directory listing showing öooo instead of öooo.

I'll try to keep tracking this bug down to its source!

04/10/07 15:17:03 changed by virdiq

Ok traced this problem back to:

  ret = WideCharToMultiByte(CP_UTF8, 0, dir->entry.cFileName, wcslen(dir->entry.cFileName)+1, filename, sz, NULL, NULL);

Line 224 of fs_dir_read in wzd_fs.c (SVN 1656).

This command is converting öooo to öooo which is bad!

I'm not sure why it is converting codepages/Unicode characters/etc? What is in the directory is what you need to send in the directory listing as-is... so why is this function even needed?

Some more info at:

04/11/07 08:25:46 changed by pollux

This is needed, because the server must be able to speak UTF-8.

The fix is to wrap the unlink() function, so the windows part of the function use the wide version of unlink (something like _wunlink() )

See http://msdn2.microsoft.com/en-us/library/1c3tczd6(VS.80).aspx

04/11/07 11:13:54 changed by virdiq

The problem I'm talking about is directory listings. The directory listing transfer is actually sending the wrong filenames to the client, which thinks it is a normal 8 bit character set with no fancy encoding.

For example, FlashFXP shows öooo as the filename instead of what it is on the disk as öooo.

So I still believe the WideCharToMultiByte?() function is wrong in its current state (?)

04/11/07 12:12:24 changed by pollux

You have to check if the client asks for UTF-8 (sends the command OPTS UTF8 ON during login sequence). The sequence 'öooo' is a valid UTF-8 encoding, displayed in iso-8859

There are 2 options:

  • the string may be double-encoded (easy to check)
  • flashfxp thinks it is iso-8859, while the server sent UTF-8

04/12/07 14:49:16 changed by virdiq

  • summary changed from high ascii characters in filenames not working with windows to extended ascii characters in filenames not working with windows.
  • milestone changed from 0.8.2 to 0.9.0.

As discussed on IRC, this is a major architectural issue in wzdftpd, I'm rolling this milestone waaayyyy forward :)

06/06/07 08:53:48 changed by virdiq

Also see #90 which is a similar issue, merged into this ticket now.