[Zope-Checkins] SVN: Zope/branches/2.10/ Merge fix for #2288: do not quote + and @ characters when forming BaseRequest and HTTPRequest URL variables

Martijn Pieters mj at zopatista.com
Sun Mar 4 11:33:01 EST 2007


Log message for revision 72972:
  Merge fix for #2288: do not quote + and @ characters when forming BaseRequest and HTTPRequest URL variables

Changed:
  U   Zope/branches/2.10/doc/CHANGES.txt
  U   Zope/branches/2.10/lib/python/ZPublisher/BaseRequest.py
  U   Zope/branches/2.10/lib/python/ZPublisher/HTTPRequest.py
  U   Zope/branches/2.10/lib/python/ZPublisher/tests/testBaseRequest.py

-=-
Modified: Zope/branches/2.10/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.10/doc/CHANGES.txt	2007-03-04 16:25:31 UTC (rev 72971)
+++ Zope/branches/2.10/doc/CHANGES.txt	2007-03-04 16:33:00 UTC (rev 72972)
@@ -8,6 +8,9 @@
 
     Bugs fixed
 
+      - Collector #2288: @ and + should not be quoted when forming
+        request URLs in BaseRequest and HTTPRequest
+
       - Undeprecated 'zLOG', which will remain a backward-compatibility
         shim for the Python logging module.
 

Modified: Zope/branches/2.10/lib/python/ZPublisher/BaseRequest.py
===================================================================
--- Zope/branches/2.10/lib/python/ZPublisher/BaseRequest.py	2007-03-04 16:25:31 UTC (rev 72971)
+++ Zope/branches/2.10/lib/python/ZPublisher/BaseRequest.py	2007-03-04 16:33:00 UTC (rev 72972)
@@ -14,7 +14,7 @@
 
 $Id$
 """
-from urllib import quote
+from urllib import quote as urllib_quote
 import xmlrpc
 from zExceptions import Forbidden, Unauthorized, NotFound
 from Acquisition import aq_base
@@ -35,6 +35,10 @@
 
 UNSPECIFIED_ROLES=''
 
+def quote(text):
+    # quote url path segments, but leave + and @ intact
+    return urllib_quote(text, '/+@')
+
 try:
     from ExtensionClass import Base
     class RequestContainer(Base):

Modified: Zope/branches/2.10/lib/python/ZPublisher/HTTPRequest.py
===================================================================
--- Zope/branches/2.10/lib/python/ZPublisher/HTTPRequest.py	2007-03-04 16:25:31 UTC (rev 72971)
+++ Zope/branches/2.10/lib/python/ZPublisher/HTTPRequest.py	2007-03-04 16:33:00 UTC (rev 72972)
@@ -15,10 +15,10 @@
 
 import re, sys, os, time, random, codecs, inspect
 from types import StringType, UnicodeType
-from BaseRequest import BaseRequest
+from BaseRequest import BaseRequest, quote
 from HTTPResponse import HTTPResponse
 from cgi import FieldStorage, escape
-from urllib import quote, unquote, splittype, splitport
+from urllib import unquote, splittype, splitport
 from copy import deepcopy
 from Converters import get_converter
 from TaintedString import TaintedString

Modified: Zope/branches/2.10/lib/python/ZPublisher/tests/testBaseRequest.py
===================================================================
--- Zope/branches/2.10/lib/python/ZPublisher/tests/testBaseRequest.py	2007-03-04 16:25:31 UTC (rev 72971)
+++ Zope/branches/2.10/lib/python/ZPublisher/tests/testBaseRequest.py	2007-03-04 16:33:00 UTC (rev 72972)
@@ -385,7 +385,17 @@
         # using default view
         self.setDefaultViewName('methonly')
         self.assertRaises(NotFound, r.traverse, 'folder2/obj2')
+        
+    def test_quoting(self):
+        """View markers should not be quoted"""
+        r = self.makeBaseRequest()
+        r.traverse('folder/obj/@@meth')
+        self.assertEqual(r['URL'], '/folder/obj/@@meth')
 
+        r = self.makeBaseRequest()
+        r.traverse('folder/obj/++view++meth')
+        self.assertEqual(r['URL'], '/folder/obj/++view++meth')
+
 def test_suite():
     return TestSuite( ( makeSuite(TestBaseRequest),
                         makeSuite(TestBaseRequestZope3Views),



More information about the Zope-Checkins mailing list