[Zope-Checkins] SVN: Zope/branches/2.9/ - Collector #1991:
ZPublisher did not deal properly with a trailing
Andreas Jung
andreas at andreas-jung.com
Sun Feb 19 07:02:46 EST 2006
Log message for revision 41691:
- Collector #1991: ZPublisher did not deal properly with a trailing
%20 in the URL
Changed:
U Zope/branches/2.9/doc/CHANGES.txt
U Zope/branches/2.9/lib/python/ZPublisher/Publish.py
U Zope/branches/2.9/lib/python/ZPublisher/tests/testPublish.py
-=-
Modified: Zope/branches/2.9/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.9/doc/CHANGES.txt 2006-02-19 11:27:56 UTC (rev 41690)
+++ Zope/branches/2.9/doc/CHANGES.txt 2006-02-19 12:02:46 UTC (rev 41691)
@@ -18,6 +18,9 @@
Bugs fixed
+ - Collector #1991: ZPublisher did not deal properly with a trailing
+ %20 in the URL
+
- Collector #1989: 'test.py' now copyied to $ZOPE_HOME/bin
during installation, which re-enables tests run from the instance
home.
Modified: Zope/branches/2.9/lib/python/ZPublisher/Publish.py
===================================================================
--- Zope/branches/2.9/lib/python/ZPublisher/Publish.py 2006-02-19 11:27:56 UTC (rev 41690)
+++ Zope/branches/2.9/lib/python/ZPublisher/Publish.py 2006-02-19 12:02:46 UTC (rev 41691)
@@ -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/2.9/lib/python/ZPublisher/tests/testPublish.py
===================================================================
--- Zope/branches/2.9/lib/python/ZPublisher/tests/testPublish.py 2006-02-19 11:27:56 UTC (rev 41690)
+++ Zope/branches/2.9/lib/python/ZPublisher/tests/testPublish.py 2006-02-19 12:02:46 UTC (rev 41691)
@@ -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