File name bad convert

Advertisement

questor
Joined:
Posts:
3
Location:
Russia, Moscow

File name bad convert

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:
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

Reply with quote

Advertisement

questor
Joined:
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?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,226
Location:
Prague, Czechia

Re: File name bad convert

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:
https://winscp.net/eng/docs/ui_login_environment

Reply with quote

questor
Joined:
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!

Reply with quote

bishop
Guest

C# .NET Character set Problem

May I force WinSCP to use other character set instead of UTF-8 unconditionally in session options of C# .NET source code ?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,226
Location:
Prague, Czechia

Re: C# .NET Character set Problem

WinSCP supports UTF-8 and system (Ansi) encoding only.

Reply with quote

Advertisement

You can post new topics in this forum