Skip to content

Commit

Permalink
- fixed a traversal regression
Browse files Browse the repository at this point in the history
  • Loading branch information
Unknown committed Feb 23, 2012
1 parent 5d03ec1 commit 1fe0935
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ZPublisher/BaseRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def traverse(self, path, response=None, validated_hook=None):
if (no_acquire_flag and
hasattr(parents[1], 'aq_base') and
not hasattr(parents[1],'__bobo_traverse__')):
base = parents[-1].aq_base
base = parents[1].aq_base
if not (hasattr(base, entry_name) or entry_name in base):
raise AttributeError(entry_name)

Expand Down
12 changes: 12 additions & 0 deletions src/ZPublisher/tests/testBaseRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def noview(self):
# Attribute without docstring.
return 'unpublishable'

def __contains__(self, name):
return False

return DummyObjectBasic

def _makeBasicObject(self):
Expand Down Expand Up @@ -194,6 +197,15 @@ def test_traverse_basic(self):
self.assertEqual(r.URL, '/folder/objBasic')
self.assertEqual(r.response.base, '')

def test_traverse_basic_no_acquire_flag(self):
root, folder = self._makeRootAndFolder()
folder._setObject('objBasic', self._makeBasicObject())
r = self._makeOne(root)
r['REQUEST_METHOD'] = 'HEAD'
r.traverse('folder/objBasic')
self.assertEqual(r.URL, '/folder/objBasic')
self.assertEqual(r.response.base, '')

def test_traverse_withDefault(self):
root, folder = self._makeRootAndFolder()
folder._setObject('objWithDefault', self._makeObjectWithDefault())
Expand Down

0 comments on commit 1fe0935

Please sign in to comment.