[Zope3-checkins] SVN: Zope3/branches/3.3/ Fixed issues 648 and 593: uploading files with non-ASCII filenames now works.

Marius Gedminas marius at pov.lt
Wed Jun 14 08:30:23 EDT 2006


Log message for revision 68627:
  Fixed issues 648 and 593: uploading files with non-ASCII filenames now works.
  
  Backported fix from trunk with
  
    svn merge -r 68625:68626 svn+ssh://svn.zope.org/repos/main/Zope3/trunk .
  
  

Changed:
  U   Zope3/branches/3.3/doc/CHANGES.txt
  U   Zope3/branches/3.3/src/zope/app/file/browser/file.txt
  U   Zope3/branches/3.3/src/zope/publisher/browser.py

-=-
Modified: Zope3/branches/3.3/doc/CHANGES.txt
===================================================================
--- Zope3/branches/3.3/doc/CHANGES.txt	2006-06-14 12:25:49 UTC (rev 68626)
+++ Zope3/branches/3.3/doc/CHANGES.txt	2006-06-14 12:30:23 UTC (rev 68627)
@@ -10,6 +10,9 @@
 
     Bugfixes
 
+      - Fixed issues 648 and 593: uploading files with non-ASCII filenames now
+        works.
+
       - Fixed issue 639: Default ITraverser ignores dict methods
 
       - Fixed issue 636: Default ITraverser can't traverse old style

Modified: Zope3/branches/3.3/src/zope/app/file/browser/file.txt
===================================================================
--- Zope3/branches/3.3/src/zope/app/file/browser/file.txt	2006-06-14 12:25:49 UTC (rev 68626)
+++ Zope3/branches/3.3/src/zope/app/file/browser/file.txt	2006-06-14 12:30:23 UTC (rev 68627)
@@ -554,3 +554,56 @@
   ...
      <li>The character set specified in the content type (ASCII) does not match file content.</li>
   ...
+
+
+Non-ASCII Filenames
+-------------------
+
+Filenames are not restricted to ASCII.
+
+  >>> print http("""
+  ... POST /+/zope.app.file.File%3D HTTP/1.1
+  ... Authorization: Basic mgr:mgrpw
+  ... Content-Type: multipart/form-data; boundary=---------------------------73793505419963331401738523176
+  ...
+  ... -----------------------------73793505419963331401738523176
+  ... Content-Disposition: form-data; name="field.contentType"
+  ...
+  ... application/octet-stream
+  ... -----------------------------73793505419963331401738523176
+  ... Content-Disposition: form-data; name="field.data"; filename="bj\xc3\xb6rn.txt.gz"
+  ... Content-Type: application/x-gzip
+  ...
+  ... \x1f\x8b\x08\x08\xcb\x48\xea\x42\x00\x03\x68\x65\x6c\x6c\x6f\x2e\
+  ... \x74\x78\x74\x00\xcb\x48\xcd\xc9\xc9\xe7\x02\x00\x20\x30\x3a\x36\
+  ... \x06\x00\x00\x00
+  ... -----------------------------73793505419963331401738523176
+  ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
+  ...
+  ... Add
+  ... -----------------------------73793505419963331401738523176
+  ... Content-Disposition: form-data; name="add_input_name"
+  ...
+  ...
+  ... -----------------------------73793505419963331401738523176--
+  ... """)
+  HTTP/1.1 303 See Other
+  Content-Length: ...
+  Content-Type: text/html;charset=utf-8
+  Location: http://localhost/@@contents.html
+  <BLANKLINE>
+  ...
+
+Since we did not specify the object name in the form, Zope 3 will use the
+filename.
+
+  >>> response = http("""
+  ... GET /bj%C3%B6rn.txt.gz HTTP/1.1
+  ... """)
+  >>> print response
+  HTTP/1.1 200 Ok
+  Content-Length: 36
+  Content-Type: application/octet-stream
+  <BLANKLINE>
+  ...
+

Modified: Zope3/branches/3.3/src/zope/publisher/browser.py
===================================================================
--- Zope3/branches/3.3/src/zope/publisher/browser.py	2006-06-14 12:25:49 UTC (rev 68626)
+++ Zope3/branches/3.3/src/zope/publisher/browser.py	2006-06-14 12:30:23 UTC (rev 68627)
@@ -596,7 +596,7 @@
                 d[m] = getattr(file,m)
 
         self.headers = aFieldStorage.headers
-        self.filename = aFieldStorage.filename
+        self.filename = unicode(aFieldStorage.filename, 'UTF-8')
 
 class RedirectingBrowserRequest(BrowserRequest):
     """Browser requests that redirect when the actual and effective URLs differ



More information about the Zope3-Checkins mailing list