Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/99.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix traversal with virtual hosting with a subsite as the VirtualHostRoot. @davisagli
14 changes: 13 additions & 1 deletion src/plone/rest/tests/test_traversal.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,19 @@ def test_virtual_hosting(self):
vhm.addToContainer(app)
obj = self.traverse(
path="/VirtualHostBase/http/localhost:8080/plone/VirtualHostRoot/"
) # noqa
)
self.assertTrue(isinstance(obj, Service), "Not a service")
del app["virtual_hosting"]

def test_virtual_hosting_subpath(self):
app = self.layer["app"]
vhm = VirtualHostMonster()
vhm.id = "virtual_hosting"
vhm.addToContainer(app)
self.portal.invokeFactory("Document", id="doc1")
obj = self.traverse(
path="/VirtualHostBase/http/localhost:8080/plone/doc1/VirtualHostRoot"
)
self.assertTrue(isinstance(obj, Service), "Not a service")
del app["virtual_hosting"]

Expand Down
5 changes: 4 additions & 1 deletion src/plone/rest/traverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ def publishTraverse(self, request, name):
try:
obj = adapter.publishTraverse(request, name)
if not IContentish.providedBy(obj) and not IService.providedBy(obj):
raise KeyError
if isinstance(obj, VirtualHostMonster):
return obj
else:
raise KeyError

# If there's no object with the given name, we get a KeyError.
# In a non-folderish context a key lookup results in an AttributeError.
Expand Down