From b0c138f7c09edd4a58a49324bc0d277837251d29 Mon Sep 17 00:00:00 2001 From: meejah Date: Mon, 24 Feb 2020 09:59:48 -0700 Subject: [PATCH] remove empty segments instead of making multiple URI's valid --- src/allmydata/web/root.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/allmydata/web/root.py b/src/allmydata/web/root.py index ab1853124..11b051042 100644 --- a/src/allmydata/web/root.py +++ b/src/allmydata/web/root.py @@ -134,10 +134,14 @@ class URIHandler(resource.Resource, object): capability it was passed). """ # this is in case a URI like "/uri/?cap=" is - # passed; returning self causes our render_GET() to be called - # which does the right thing. + # passed -- we re-direct to the non-trailing-slash version so + # that there is just one valid URI for "uri" resource. if not name: - return self + u = URL.from_text(req.uri.decode('utf8')) + u = u.replace( + path=(s for s in u.path if s), # remove empty segments + ) + return redirectTo(u.to_uri().to_text().encode('utf8'), req) try: node = self.client.create_node_from_uri(name) return directory.make_handler_for(node, self.client)