Merge pull request #724 from sajith/3312.webui-directory-fix

Fix for "the webapi does not allow empty pathname components"

Fixes: ticket:3312
This commit is contained in:
Sajith Sasidharan 2020-06-17 10:55:21 -04:00 committed by GitHub
commit 7a23c8ed6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 8 deletions

View File

@ -0,0 +1 @@
Make directory page links work.

View File

@ -1269,5 +1269,5 @@ class TrialTestCase(_TrialTestCase):
if six.PY2: if six.PY2:
if isinstance(msg, six.text_type): if isinstance(msg, six.text_type):
return super(self, TrialTestCase).fail(msg.encode("utf8")) return super(TrialTestCase, self).fail(msg.encode("utf8"))
return super(self, TrialTestCase).fail(msg) return super(TrialTestCase, self).fail(msg)

View File

@ -102,12 +102,21 @@ class DirectoryNodeHandler(ReplaceMeMixin, Resource, object):
# trying to replicate what I have observed as Nevow behavior # trying to replicate what I have observed as Nevow behavior
# for these nodes, which is that a URI like # for these nodes, which is that a URI like
# "/uri/URI%3ADIR2%3Aj...vq/" (that is, with a trailing slash # "/uri/URI%3ADIR2%3Aj...vq/" (that is, with a trailing slash
# or no further children) renders "this" page # or no further children) renders "this" page. We also need
# to reject "/uri/URI:DIR2:..//", so we look at postpath.
name = name.decode('utf8') name = name.decode('utf8')
if not name: if not name and req.postpath != ['']:
raise EmptyPathnameComponentError( return self
u"The webapi does not allow empty pathname components",
) # Rejecting URIs that contain empty path pieces (for example:
# "/uri/URI:DIR2:../foo//new.txt" or "/uri/URI:DIR2:..//") was
# the old nevow behavior and it is encoded in the test suite;
# we will follow suit.
for segment in req.prepath:
if not segment:
raise EmptyPathnameComponentError(
u"The webapi does not allow empty pathname components",
)
d = self.node.get(name) d = self.node.get(name)
d.addBoth(self._got_child, req, name) d.addBoth(self._got_child, req, name)

View File

@ -31,7 +31,7 @@
<div class="well sidebar-nav"> <div class="well sidebar-nav">
<ul class="nav nav-list"> <ul class="nav nav-list">
<li class="toolbar-item" t:render="welcome" /> <li class="toolbar-item" t:render="welcome" />
<li class="toolbar-item"><a href=".">Refresh</a></li> <li class="toolbar-item"><a href="">Refresh</a></li>
<li class="toolbar-item"><a href="?t=info">More info on this directory</a></li> <li class="toolbar-item"><a href="?t=info">More info on this directory</a></li>
<li class="toolbar-item" t:render="show_readonly" /> <li class="toolbar-item" t:render="show_readonly" />
</ul> </ul>