[Zope-Checkins] SVN: Zope/branches/Zope-2_8-branch/ - Collector #1991: ZPublisher did not deal properly with a trailing

Andreas Jung andreas at andreas-jung.com
Sun Feb 19 07:05:46 EST 2006


Log message for revision 41693:
  
        - Collector #1991: ZPublisher did not deal properly with a trailing
          %20 in the URL
  

Changed:
  U   Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
  U   Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/Publish.py
  U   Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/tests/testPublish.py

-=-
Modified: Zope/branches/Zope-2_8-branch/doc/CHANGES.txt
===================================================================
--- Zope/branches/Zope-2_8-branch/doc/CHANGES.txt	2006-02-19 12:03:16 UTC (rev 41692)
+++ Zope/branches/Zope-2_8-branch/doc/CHANGES.txt	2006-02-19 12:05:45 UTC (rev 41693)
@@ -27,6 +27,9 @@
 
     Bugs Fixed
 
+      - Collector #1991: ZPublisher did not deal properly with a trailing
+        %20 in the URL
+
       - Collector #2013: improved XHTML conformance of error messages,
         some of which did not close '<p>' tags.
 
@@ -40,6 +43,7 @@
 
     Bugs Fixed
 
+
       - Collector #1939: When running as a service, Zope could
         potentially collect too much log output filling the NT Event
         Log. When that happened, a 'print' during exception handling

Modified: Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/Publish.py
===================================================================
--- Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/Publish.py	2006-02-19 12:03:16 UTC (rev 41692)
+++ Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/Publish.py	2006-02-19 12:05:45 UTC (rev 41693)
@@ -93,8 +93,9 @@
         if bobo_before is not None:
             bobo_before()
 
-        # Get a nice clean path list:
-        path=request_get('PATH_INFO').strip()
+        # Get the path list.
+        # According to RFC1738 a trailing space in the path is valid.
+        path=request_get('PATH_INFO')
 
         request['PARENTS']=parents=[object]
 

Modified: Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/tests/testPublish.py
===================================================================
--- Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/tests/testPublish.py	2006-02-19 12:03:16 UTC (rev 41692)
+++ Zope/branches/Zope-2_8-branch/lib/python/ZPublisher/tests/testPublish.py	2006-02-19 12:05:45 UTC (rev 41693)
@@ -266,7 +266,66 @@
     """
     pass
 
+class ObjectNotFound:
+    """Mock object for traversing to.
+    """
 
+    def __call__(self):
+        tracer.append('ObjectNotFound')
+        return 'ObjectNotFound'
+
+
+class PathRequest(Request):
+    def __init__(self, path):
+        self.PATH_INFO = path
+        Request.__init__(self)
+
+    def get(self, a, b=''):
+        if a == 'PATH_INFO':
+            return self.PATH_INFO
+        else:
+            return ''
+
+    def traverse(self, path, validated_hook):
+        if path == self.PATH_INFO:
+            return Object()
+        else:
+            return ObjectNotFound()
+
+def testPublishPath():
+    """
+    Tests to ensure that publish passes paths through to the request without
+    stripping spaces (as this can lead to google indexing pages with a trailing
+    space when someone has a typo in an href to you're site). Zope bug #1991.
+
+    >>> from ZPublisher.Publish import publish
+
+    Without the trailing space, should work normally
+
+    >>> tracer.reset()
+    >>> request = PathRequest('/foo')
+    >>> response = publish(request, module_name, after_list)
+    >>> tracer.showTracedPath()
+    begin
+    __call__
+    commit
+
+    Now with a trailing space, should also work normally, but in zope 2.9.0
+    and earlier publish did a strip() on the path so instead of __call__ you
+    an ObjectNotFound in the trace.
+
+    >>> tracer.reset()
+    >>> request = PathRequest('/foo ')
+    >>> response = publish(request, module_name, after_list)
+    >>> tracer.showTracedPath()
+    begin
+    __call__
+    commit
+
+    """
+    pass
+
+
 from zope.testing import doctest
 
 def test_suite():



More information about the Zope-Checkins mailing list