[Zope] illegal characters in url error

Paul Rudin paul.rudin@ntlworld.com
25 Feb 2002 09:41:31 +0000


I'm new to both zope and python, so I hope you'll forgive my
ignorance.

I'm writing a simple file upload web page. I've got it working most
of the time; however when file names have certain characters in them
I get errors like this:

  Zope Error
  Zope has encountered an error while publishing this resource.

  Error Type: Bad Request
  Error Value: The id "[X=X].foo" contains characters illegal in URLs.



The code generating this error is as follows:


origfilename=file.filename
id=origfilename[max(string.rfind(origfilename, '/'),
        		string.rfind(origfilename, '\\'),
			string.rfind(origfilename, ':'),
			)+1:]
context.DemoArchive.manage_addFile(id,file, demo_title)

I thought that using quote_url_plus would solve this, so I changed to:

origfilename=file.filename
id=origfilename[max(string.rfind(origfilename, '/'),
        		string.rfind(origfilename, '\\'),
			string.rfind(origfilename, ':'),
			)+1:]
id=url_quote_plus(id)
context.DemoArchive.manage_addFile(id,file, demo_title)


However I get the same error with the new string:

  The id "%5BX%3DX%5D.foo" contains characters illegal in URLs


Can anyone tell me how to fix this please?


TIA.