473,464 Members | 1,476 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

FTP filename escaping

Hello,

I feel ashamed, but my google-fu betrayed me again.

How do I escape filenames when using ftplib? I'd like to download it
and upload on ftp again...
toDown = self.ftpMaster.nlst()
for fileDown in toDown:
f = tmpfile()
# download
self.ftpMaster.retrbinary(''.join(['RETR ', fileDown]),
f.write)
f.seek(0)
self.ftpMirror.storbinary(''.join(["STOR ", fileDown]), f,
1024)
f.close()

Problem is when fileDown contains special characters / spaces and so
on. I hoped for some ftplib.quote(), urllib.quote() or quote_plus() is
not functional either.

Is there such a function in stdlib or do I have to read through
specification and write it?

Thank You,

Almad

May 11 '06 #1
3 2723
OK, after some investigation...problem is in non-latin characters in
filenames on ftp.

Yes, users should be killed for this, but I would like to handle it
somehow...

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

Thank You,

Almad

May 11 '06 #2
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

May 11 '06 #3
Serge Orlov wrote:
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.


Yes but you can take their toys away. :)
May 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ralph Freshour | last post by:
I have a PHP web app using MySQL - when I save a .jpg file named test's.jpg I see that the filename on the unix server is: test\'s.jpg - the filename I end up saving in my SQL table is named...
2
by: Fuzzyman | last post by:
I know I *could* look this up in the relevant RFC... but I thought someone might know it off the top of their head. I'm offering files for download via a CGI. I am inserting the filename into...
3
by: The wee free man | last post by:
Hi, Except for using the hosts url masking, there seems to be a way to use escaping characters and javascript to hide the filename in the browsers address bar. Does anyone know how? I can't...
1
by: Matt | last post by:
In test() method: var path="C:\test\hello.txt"; //returns -1 for path.lastIndexOf("\\"). why?? var pos=path.lastIndexOf("\\"); //return -1 But in showFile() method: We are able to get the...
1
by: David Henderson | last post by:
I know 'disable-output-escaping' has been discussed in the past, but I can't put my finger on any of the threads to see if my current problem is addressed. Sorry for re-asking the question if it...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.