[Zope-Checkins] SVN: Zope/trunk/ - Collector #1991: ZPublisher did
not deal properly with a trailing
Andreas Jung
andreas at andreas-jung.com
Sun Feb 19 07:03:16 EST 2006
Log message for revision 41692:
- Collector #1991: ZPublisher did not deal properly with a trailing
%20 in the URL
Changed:
U Zope/trunk/doc/CHANGES.txt
U Zope/trunk/lib/python/ZPublisher/Publish.py
U Zope/trunk/lib/python/ZPublisher/tests/testPublish.py
-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt 2006-02-19 12:02:46 UTC (rev 41691)
+++ Zope/trunk/doc/CHANGES.txt 2006-02-19 12:03:16 UTC (rev 41692)
@@ -197,6 +197,9 @@
Bugs Fixed
+ - Collector #1991: ZPublisher did not deal properly with a trailing
+ %20 in the URL
+
- zope.app.introspector was not included with the source archive
- Collector #2013: improved XHTML conformance of error messages,
Modified: Zope/trunk/lib/python/ZPublisher/Publish.py
===================================================================
--- Zope/trunk/lib/python/ZPublisher/Publish.py 2006-02-19 12:02:46 UTC (rev 41691)
+++ Zope/trunk/lib/python/ZPublisher/Publish.py 2006-02-19 12:03:16 UTC (rev 41692)
@@ -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/trunk/lib/python/ZPublisher/tests/testPublish.py
===================================================================
--- Zope/trunk/lib/python/ZPublisher/tests/testPublish.py 2006-02-19 12:02:46 UTC (rev 41691)
+++ Zope/trunk/lib/python/ZPublisher/tests/testPublish.py 2006-02-19 12:03:16 UTC (rev 41692)
@@ -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