From 2b4b8e11cec2d2086da31ed26f0c9e6e4eaacbeb Mon Sep 17 00:00:00 2001 From: meejah Date: Fri, 27 Sep 2019 11:52:27 -0600 Subject: [PATCH] urls are bytes in Twisted --- src/allmydata/test/web/test_root.py | 7 +++---- src/allmydata/web/root.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/allmydata/test/web/test_root.py b/src/allmydata/test/web/test_root.py index 113efad5b..40bb2bf9a 100644 --- a/src/allmydata/test/web/test_root.py +++ b/src/allmydata/test/web/test_root.py @@ -35,13 +35,12 @@ class RenderSlashUri(unittest.TestCase): """ def setUp(self): - self.request = DummyRequest("/uri") + self.request = DummyRequest(b"/uri") self.request.fields = {} def prepathURL(): - return "http://127.0.0.1.99999/{}".format( - "/".join(self.request.prepath) - ) + return b"http://127.0.0.1.99999/" + b"/".join(self.request.prepath) + self.request.prePathURL = prepathURL self.client = Mock() self.res = URIHandler(self.client) diff --git a/src/allmydata/web/root.py b/src/allmydata/web/root.py index c638c64e3..0e241cfc3 100644 --- a/src/allmydata/web/root.py +++ b/src/allmydata/web/root.py @@ -75,7 +75,7 @@ class URIHandler(resource.Resource, object): redir_uri = redir_uri.child(urllib.quote(uri_arg).decode('utf8')) # add back all the query args that AREN'T "?uri=" for k, values in req.args.items(): - if k != "uri": + if k != b"uri": for v in values: redir_uri = redir_uri.add(k.decode('utf8'), v.decode('utf8')) return redirectTo(redir_uri.to_text().encode('utf8'), req)