[Checkins] SVN: Sandbox/nadako/zope.publisher/ Add a fix for IE that gives full path instead of just file name on file upload.
Dan Korostelev
nadako at gmail.com
Tue Aug 25 12:34:29 EDT 2009
Log message for revision 103207:
Add a fix for IE that gives full path instead of just file name on file upload.
Changed:
U Sandbox/nadako/zope.publisher/CHANGES.txt
U Sandbox/nadako/zope.publisher/src/zope/publisher/browser.py
U Sandbox/nadako/zope.publisher/src/zope/publisher/tests/test_browserrequest.py
-=-
Modified: Sandbox/nadako/zope.publisher/CHANGES.txt
===================================================================
--- Sandbox/nadako/zope.publisher/CHANGES.txt 2009-08-25 16:17:54 UTC (rev 103206)
+++ Sandbox/nadako/zope.publisher/CHANGES.txt 2009-08-25 16:34:29 UTC (rev 103207)
@@ -29,6 +29,9 @@
- Removed behavior of doing a time.sleep in the supportsRetry http request.
+- Add a fix for Internet Explorer versions that upload files will full
+ filesystem paths as filenames.
+
3.8.0 (2009-05-23)
------------------
Modified: Sandbox/nadako/zope.publisher/src/zope/publisher/browser.py
===================================================================
--- Sandbox/nadako/zope.publisher/src/zope/publisher/browser.py 2009-08-25 16:17:54 UTC (rev 103206)
+++ Sandbox/nadako/zope.publisher/src/zope/publisher/browser.py 2009-08-25 16:34:29 UTC (rev 103207)
@@ -623,7 +623,10 @@
d[m] = getattr(file,m)
self.headers = aFieldStorage.headers
- self.filename = unicode(aFieldStorage.filename, 'UTF-8')
+ filename = unicode(aFieldStorage.filename, 'UTF-8')
+ # fix for IE full paths
+ filename = filename[filename.rfind('\\')+1:].strip()
+ self.filename = filename
class RedirectingBrowserRequest(BrowserRequest):
"""Browser requests that redirect when the actual and effective URLs differ
Modified: Sandbox/nadako/zope.publisher/src/zope/publisher/tests/test_browserrequest.py
===================================================================
--- Sandbox/nadako/zope.publisher/src/zope/publisher/tests/test_browserrequest.py 2009-08-25 16:17:54 UTC (rev 103206)
+++ Sandbox/nadako/zope.publisher/src/zope/publisher/tests/test_browserrequest.py 2009-08-25 16:34:29 UTC (rev 103207)
@@ -47,6 +47,15 @@
-----------------------------1--
""" % ('test' * 1000)
+IE_FILE_BODY = """-----------------------------1
+Content-Disposition: form-data; name="upload"; filename="C:\\Windows\\notepad.exe"
+Content-Type: text/plain
+
+Some data
+-----------------------------1--
+"""
+
+
def publish(request):
publish_(request, handle_errors=0)
@@ -200,6 +209,11 @@
request.processInputs()
self.assert_(request.form['upload'].name)
+ request = self._createRequest(extra, body=IE_FILE_BODY)
+ request.processInputs()
+ self.assertEquals(request.form['upload'].filename, 'notepad.exe')
+
+
def testDefault2(self):
extra = {'PATH_INFO': '/folder/item2/view'}
request = self._createRequest(extra)
More information about the Checkins
mailing list