[Checkins] SVN: zope.publisher/trunk/src/zope/publisher/ Bug fixed:

Jim Fulton jim at zope.com
Sun Apr 6 13:45:25 EDT 2008


Log message for revision 85125:
  Bug fixed:
  
  - A previous fix to handle posting of non-form data broke handling of
    form data with extra information in the content type, as in::
  
  application/x-www-form-urlencoded; charset=UTF-8
  

Changed:
  U   zope.publisher/trunk/src/zope/publisher/browser.py
  U   zope.publisher/trunk/src/zope/publisher/tests/test_browserrequest.py

-=-
Modified: zope.publisher/trunk/src/zope/publisher/browser.py
===================================================================
--- zope.publisher/trunk/src/zope/publisher/browser.py	2008-04-06 17:41:00 UTC (rev 85124)
+++ zope.publisher/trunk/src/zope/publisher/browser.py	2008-04-06 17:45:25 UTC (rev 85125)
@@ -259,7 +259,7 @@
             if self.method == 'POST':
                 content_type = self._environ.get('CONTENT_TYPE')
                 if content_type and not (
-                    content_type == 'application/x-www-form-urlencoded'
+                    content_type.startswith('application/x-www-form-urlencoded')
                     or
                     content_type.startswith('multipart/')
                     ):

Modified: zope.publisher/trunk/src/zope/publisher/tests/test_browserrequest.py
===================================================================
--- zope.publisher/trunk/src/zope/publisher/tests/test_browserrequest.py	2008-04-06 17:41:00 UTC (rev 85124)
+++ zope.publisher/trunk/src/zope/publisher/tests/test_browserrequest.py	2008-04-06 17:45:25 UTC (rev 85125)
@@ -11,10 +11,7 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""Browser Request Tests
 
-$Id$
-"""
 import sys
 import unittest
 from StringIO import StringIO
@@ -489,6 +486,26 @@
         request.processInputs()
         self.assertEqual(request.bodyStream.read(), 'test body')
 
+    def test_post_body_not_necessarily(self):
+        request = self._createRequest(
+            dict(REQUEST_METHOD='POST',
+                 CONTENT_TYPE='application/x-www-form-urlencoded',
+                 ),
+            'x=1&y=2')
+        request.processInputs()
+        self.assertEqual(request.bodyStream.read(), '')
+        self.assertEqual(dict(request.form), dict(x='1', y='2'))
+
+        request = self._createRequest(
+            dict(REQUEST_METHOD='POST',
+                 CONTENT_TYPE=('application/x-www-form-urlencoded'
+                               '; charset=UTF-8'),
+                 ),
+            'x=1&y=2')
+        request.processInputs()
+        self.assertEqual(request.bodyStream.read(), '')
+        self.assertEqual(dict(request.form), dict(x='1', y='2'))
+
 class TestBrowserPublication(TestPublication):
     implements(IBrowserPublication)
 



More information about the Checkins mailing list