473,602 Members | 2,887 Online
Bytes | Software Development & Data Engineering Community
+ 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(''.j oin(['RETR ', fileDown]),
f.write)
f.seek(0)
self.ftpMirror. storbinary(''.j oin(["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 2733
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
6587
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 test's.jpg - when I use an image tag to display the photo on my web page, no image displays. I tried to strip the slash out of the filename but the image still won't display on the web page - maybe I'm all goofed up here and don't understand what's...
2
2172
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 the relevant http header. Where the filename contains spaces firefox truncates it - which is probably correct behaviour for firefox - but annoying :-) Which is the right function to escape the filename urllib.quote or urllib.quote_plus ?
3
4540
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 seem to find an example online... Thanks Vince
1
16343
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 filename. The only difference is test() hardcode the path, but in showFile() we gets the path from the file dialog.
1
5460
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 has already been answered... I have an XML doc that I am transforming via XSLT and JavaScript in the browser. This allows me to return unsorted data to the browser and allow the user to sort it with a mouseclick and not hit the server just...
0
7921
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8056
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8270
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6730
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5870
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5440
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3901
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1256
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.