[Checkins] SVN: zope.publisher/branches/3.5/ Move any ``QUERY_STRING`` submitted with a POST to a new key in the environment.

Tres Seaver tseaver at palladion.com
Mon Apr 6 11:57:26 EDT 2009


Log message for revision 98932:
  Move any ``QUERY_STRING`` submitted with a POST to a new key in the environment.
  
  o The new key is``X-POST-QUERY_STRING``.
  
  o This move prevents the Python 2.6 version of ``cgi.FieldStorage`` from
    concatenating the query string  onto the form data.
  

Changed:
  U   zope.publisher/branches/3.5/CHANGES.txt
  U   zope.publisher/branches/3.5/src/zope/publisher/browser.py
  U   zope.publisher/branches/3.5/src/zope/publisher/tests/test_browserrequest.py

-=-
Modified: zope.publisher/branches/3.5/CHANGES.txt
===================================================================
--- zope.publisher/branches/3.5/CHANGES.txt	2009-04-06 14:58:03 UTC (rev 98931)
+++ zope.publisher/branches/3.5/CHANGES.txt	2009-04-06 15:57:26 UTC (rev 98932)
@@ -4,6 +4,10 @@
 3.5.7 (unreleased)
 ------------------
 
+- Move any ``QUERY_STRING`` submitted with a POST request to a new key in
+  the environment, ``X-POST-QUERY_STRING``, to prevent the Python 2.6 version
+  of ``cgi.FieldStorage`` from concatenating it onto the form data.
+
 - Pin buildout to the Zope 3.4.0 KGS index.
 
 3.5.6 (2009-02-14)

Modified: zope.publisher/branches/3.5/src/zope/publisher/browser.py
===================================================================
--- zope.publisher/branches/3.5/src/zope/publisher/browser.py	2009-04-06 14:58:03 UTC (rev 98931)
+++ zope.publisher/branches/3.5/src/zope/publisher/browser.py	2009-04-06 15:57:26 UTC (rev 98932)
@@ -267,6 +267,11 @@
                     # consumes the body and we have no good place to put it.
                     # So we just won't call FieldStorage. :)
                     return
+                # Python 2.6 notices QS-on-POST, which breaks BBB for us.
+                # Suppress that.
+                if 'QUERY_STRING' in self._environ:
+                    env = self._environ
+                    env['X-POST-QUERY_STRING'] = env.pop('QUERY_STRING')
         else:
             fp = None
 

Modified: zope.publisher/branches/3.5/src/zope/publisher/tests/test_browserrequest.py
===================================================================
--- zope.publisher/branches/3.5/src/zope/publisher/tests/test_browserrequest.py	2009-04-06 14:58:03 UTC (rev 98931)
+++ zope.publisher/branches/3.5/src/zope/publisher/tests/test_browserrequest.py	2009-04-06 15:57:26 UTC (rev 98932)
@@ -505,6 +505,8 @@
         request.processInputs()
         self.assertEqual(request.bodyStream.read(), '')
         self.assertEqual(dict(request.form), dict(x='1', y='2'))
+        self.assertEqual(request.environment['X-POST-QUERY_STRING'],
+                         'a=5&b:int=6')
 
 class TestBrowserPublication(TestPublication):
     implements(IBrowserPublication)



More information about the Checkins mailing list