FTP filename escaping

Serge Orlov Serge.Orlov at gmail.com
Thu May 11 17:46:39 EDT 2006


Almad wrote:
> OK, after some investigation...problem is in non-latin characters in
> filenames on ftp.
>
> Yes, users should be killed for this,

It's futile, users will always find a way to crash you program :) And
you can't kill them all, there are too many of them.

> but I would like to handle it
> somehow...

It depends on what you're actually doing. Did you write the ftp server?
Or do you have any information about server (OS etc...)? Is your client
the only client who can upload? Do you care how file names actually
look interally in the server?

> I can't figure out how it's handled by protocol, ftplib seems to just
> strip those characters...

I believe filename == sequence of bytes terminated by newline byte. I
doubt ftplib strips bytes over 127. Even if it does, copy it to your
private module collection as ftplibng.py, fix it and import ftplibng as
ftplib




More information about the Python-list mailing list