Hello,
I'm a user of lftp. Now I'm using lftp 4.0.5 on FreeBSD 8.0-STABLE.
I found that there's a problem in lftp.
We are using ProFTPD as the FTP server. Here, we must serve the files
in GBK encoding, since the windows clients in China expect GBK encoded
text from the server...
So we set "UseEncoding GBK GBK" at the server side.
By default, proftpd reports "UTF8" and "LANG ..." in FEAT. But with
our setting, it does not report "UTF8". That's right, since we forced
the clients to use GBK encoding.
However, lftp still issues a "LANG" command after the FEAT response.
When it receives the response of LANG, it sets encoding to UTF-8.
Since the server uses GBK in fact, the filenames in Chinese are
garbled.
Since there's such passage in RFC 2640:
- Clients MUST support the FEAT command and recognize the "UTF8"
feature (defined in 3.2 above) to determine if a server supports
UTF-8 encoding.
So I think that lftp should check that if UTF8 is supported, and if
true, set the connection encoding to UTF8.
I made such a patch:
--- src/ftpclass.cc.orig 2010-04-29 17:20:28.000000000 +0800
+++ src/ftpclass.cc 2010-04-29 17:20:42.000000000 +0800
@@ -4100,8 +4100,11 @@
case Expect::LANG:
if(is2XX(act))
{
- conn->utf8_activated=true;
- conn->SetControlConnectionTranslation("UTF-8");
+ if (conn->utf8_supported)
+ {
+ conn->utf8_activated=true;
+ conn->SetControlConnectionTranslation("UTF-8");
+ }
}
else if(act==530)
conn->tune_after_login=true;
And it works correctly here, with ProFTPd.
I understand that maybe some servers do not report "UTF8" in the FEAT,
but report "LANG", and supports UTF8. So maybe this needs more work.
Thanks for the great work in creating lftp!
--
Cheers,
Henry
--- src/ftpclass.cc.orig 2010-04-29 17:20:28.000000000 +0800
+++ src/ftpclass.cc 2010-04-29 17:20:42.000000000 +0800
@@ -4100,8 +4100,11 @@
case Expect::LANG:
if(is2XX(act))
{
- conn->utf8_activated=true;
- conn->SetControlConnectionTranslation("UTF-8");
+ if (conn->utf8_supported)
+ {
+ conn->utf8_activated=true;
+ conn->SetControlConnectionTranslation("UTF-8");
+ }
}
else if(act==530)
conn->tune_after_login=true;