From 0b46b1a6147b71476789ac8abefcd44cea21369b Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 17 Aug 2024 18:17:40 +0000 Subject: [PATCH] fix some vproxy issues (#93): * navpane would always feed the vproxy paths into the tree instead of only when necessary (the initial load) * mkdir would return `X-New-Dir` without the `rp-loc` prefix * chpw and some other redirects also sent raw vpaths Reported-by: @iridial --- copyparty/httpcli.py | 14 ++++++++------ tests/util.py | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 6747bc0d..dd153ff9 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -968,10 +968,10 @@ class HttpCli(object): status: int = 200, use302: bool = False, ) -> bool: - vp = self.args.RS + vpath + vp = self.args.SRS + vpath html = self.j2s( "msg", - h2='{} /{}'.format( + h2='%s %s' % ( quotep(vp) + suf, flavor, html_escape(vp, crlf=True) + suf ), pre=msg, @@ -979,7 +979,7 @@ class HttpCli(object): ).encode("utf-8", "replace") if use302: - self.reply(html, status=302, headers={"Location": "/" + vpath}) + self.reply(html, status=302, headers={"Location": vp}) else: self.reply(html, status=status) @@ -2407,7 +2407,7 @@ class HttpCli(object): if ok: msg = "new password OK" - redir = "/?h" if ok else "" + redir = (self.args.SRS + "?h") if ok else "" html = self.j2s("msg", h1=msg, h2='ack', redir=redir) self.reply(html.encode("utf-8")) return True @@ -2512,7 +2512,7 @@ class HttpCli(object): except: raise Pebkac(500, min_ex()) - self.out_headers["X-New-Dir"] = quotep(vpath) + self.out_headers["X-New-Dir"] = quotep(self.args.RS + vpath) if dav: self.reply(b"", 201) @@ -4102,7 +4102,9 @@ class HttpCli(object): dst = dst[len(top) + 1 :] ret = self.gen_tree(top, dst, self.uparam.get("k", "")) - if self.is_vproxied: + if self.is_vproxied and not self.uparam["tree"]: + # uparam is '' on initial load, which is + # the only time we gotta fill in the blanks parents = self.args.R.split("/") for parent in reversed(parents): ret = {"k%s" % (parent,): ret, "a": []} diff --git a/tests/util.py b/tests/util.py index 71dba7ff..04d036d7 100644 --- a/tests/util.py +++ b/tests/util.py @@ -170,6 +170,7 @@ class Cfg(Namespace): s_wr_sz=256 * 1024, sort="href", srch_hits=99999, + SRS="/", th_covers=["folder.png"], th_coversd=["folder.png"], th_covers_set=set(["folder.png"]),