[Checkins] SVN: zope.publisher/trunk/ An untested code path that incorrectly attempted to construct a NotFound
Benji York
benji at zope.com
Sat Feb 14 10:13:59 EST 2009
Log message for revision 96537:
An untested code path that incorrectly attempted to construct a NotFound
was fixed, with a test.
Changed:
U zope.publisher/trunk/CHANGES.txt
U zope.publisher/trunk/src/zope/publisher/base.py
U zope.publisher/trunk/src/zope/publisher/tests/test_http.py
-=-
Modified: zope.publisher/trunk/CHANGES.txt
===================================================================
--- zope.publisher/trunk/CHANGES.txt 2009-02-14 15:12:49 UTC (rev 96536)
+++ zope.publisher/trunk/CHANGES.txt 2009-02-14 15:13:58 UTC (rev 96537)
@@ -4,9 +4,12 @@
3.5.6 (unreleased)
------------------
-* ...
+Bugs fixed:
+* An untested code path that incorrectly attempted to construct a NotFound was
+ fixed, with a test.
+
3.5.5 (2009-02-04)
------------------
Modified: zope.publisher/trunk/src/zope/publisher/base.py
===================================================================
--- zope.publisher/trunk/src/zope/publisher/base.py 2009-02-14 15:12:49 UTC (rev 96536)
+++ zope.publisher/trunk/src/zope/publisher/base.py 2009-02-14 15:13:58 UTC (rev 96537)
@@ -380,11 +380,14 @@
if not item or item == '.':
continue
elif item == '..':
+ # try to remove the last name
try:
del clean[-1]
except IndexError:
- raise NotFound('..')
- else: clean.append(item)
+ # the list of names was empty, so do nothing and let the
+ # string '..' be placed on the list
+ pass
+ clean.append(item)
clean.reverse()
self.setTraversalStack(clean)
Modified: zope.publisher/trunk/src/zope/publisher/tests/test_http.py
===================================================================
--- zope.publisher/trunk/src/zope/publisher/tests/test_http.py 2009-02-14 15:12:49 UTC (rev 96536)
+++ zope.publisher/trunk/src/zope/publisher/tests/test_http.py 2009-02-14 15:13:58 UTC (rev 96537)
@@ -34,6 +34,7 @@
from zope.publisher.http import HTTPInputStream, DirectResult
from zope.publisher.publish import publish
from zope.publisher.base import DefaultPublication
+from zope.publisher.interfaces import NotFound
from zope.publisher.interfaces.http import IHTTPRequest, IHTTPResponse
from zope.publisher.interfaces.http import IHTTPApplicationResponse
from zope.publisher.interfaces import IResponse
@@ -225,6 +226,23 @@
''.join(response.consumeBody())
)
+ def test_double_dots(self):
+ # the code that parses PATH_INFO once tried to raise NotFound if the
+ # path it was given started with double-dots; unfortunately it didn't
+ # do it correctly, so it instead generated this error when trying to
+ # raise NotFound:
+ # TypeError: __init__() takes at least 3 arguments (2 given)
+
+ # It really shouldn't generate NotFound because it doesn't have enough
+ # context to do so, and the publisher will raise it anyway given
+ # improper input. It was fixed and this test added.
+
+ request = self._createRequest(extra_env={'PATH_INFO': '..'})
+ self.assertRaises(NotFound, publish, request, handle_errors=0)
+
+ request = self._createRequest(extra_env={'PATH_INFO': '../folder'})
+ self.assertRaises(NotFound, publish, request, handle_errors=0)
+
def test_repr(self):
request = self._createRequest()
expect = '<%s.%s instance URL=http://foobar.com>' % (
More information about the Checkins
mailing list