Topic "File name bad convert"

Author Message
questor
[View user's profile]

Joined: 2015-06-18
Posts: 3
Location: Russia, Moscow
Found strange bug in filenames displaying after reconnect.

Steps to reproduce.



Step 1.

Centos 6.6 webserver, locale: LANG=ru_RU.UTF-8
putty session, Remote charset is UTF-8 (Window -> Translation)
let's create file with russian letters in filename:
Code:

cd /www/mysite1.ru/www/
echo utf8 > Файл1.txt
ls -a
.  ..  Файл1.txt


That's good. Open firefox, see http:// mysite.ru/Файл1.txt - it showed correctly, here is nginx's access_log:

x.x.x.x - - [18/Jun/2015:18:13:29 +0300] "GET /%D0%A4%D0%B0%D0%B9%D0%BB1.txt HTTP/1.1" 200 5 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0"

Step 2.
Windows 8.1 workstation, russian codepage (cp1251) installed. WinSCP 5.7.4 5553, portable edition with default settings. Used protocol - SFTP.
Let's create file with russian letters in filename, for example - Файл2.txt
Open /www/mysite1.ru/www folder, then create subfolder winsp_uploaded and copy our Файл2.txt to this subfolder.
Open firefox, still OK.

Step 3.
Let's create an file with bad encode on unix server (i've copied the ones from old hosting via winscp < 5.1.7)
cd /www/mysite1.ru/www/
mkdir bad_file
cd bad_file
echo utf8 > Файл3.txt
convmv -futf8 -tcp1251 * --notest
mv "./Файл3.txt" "./▒▒▒▒3.txt"
Ready!

So.
Open winscp, then:
1. open folder /www/mysite1.ru/www/ - filename looks good. It's OKAY.
2. open folder /www/mysite1.ru/www/bad_file - filename looks... good. Hmm.. OK.
3. Go up to /www/mysite1.ru/www/ and press Ctrl+R (or wait for reconnect) -- and filename in /www/mysite1.ru/www/ is shown as Файл1.txt Why??

Last edited by questor on 2015-06-18 18:35; edited 4 times in total
Advertisements
questor
[View user's profile]

Joined: 2015-06-18
Posts: 3
Location: Russia, Moscow
Questions.

1. How can i understand if my filename-from-old-hosting is broken? (winscp shows me such files as good)

2. Why bad files shows as ok? if filename is not valid -- i expect it looks as broken (and i can correct such filename manually or by script)

3. Why winscsp shows good filenames as bad after reconnecting to 'bad' folder?

4. It looks like winscp knows NOTHING about real filename encoding and... tries to guess/divine it. Really so?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
With default configuration in SFTP version 3 (or older) WinSCP starts by using UTF-8, falling back to Ansi, whenever it receives a non-UTF-8 string from the server.
This is because until SFTP version 4, no encoding was mandated by an SFTP specification, so some servers use UTF-8, some other encoding.
You can force WinSCP to use UTF-8 unconditionally in session options:
http://winscp.net/eng/docs/ui_login_environment
questor
[View user's profile]

Joined: 2015-06-18
Posts: 3
Location: Russia, Moscow
Oh, it's brilliant! Set Utf-8 to 'On' for connection is best way to view bad filenames.
Thank you, Martin!
bishop

Guest


May I force WinSCP to use other character set instead of UTF-8 unconditionally in session options of C# .NET source code ?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
WinSCP supports UTF-8 and system (Ansi) encoding only.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License