From 3966266207ee656302dc59d3f00f888657e63285 Mon Sep 17 00:00:00 2001
From: ed
Date: Tue, 25 Jul 2023 15:14:47 +0000
Subject: [PATCH] remember ?edit and trailing-slash during login redirect
---
copyparty/httpcli.py | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py
index 19fe7cc6..b6c9caeb 100644
--- a/copyparty/httpcli.py
+++ b/copyparty/httpcli.py
@@ -141,6 +141,7 @@ class HttpCli(object):
self.vn = self.asrv.vfs
self.rem = " "
self.vpath = " "
+ self.vpaths = " "
self.uname = " "
self.pw = " "
self.rvol = [" "]
@@ -384,6 +385,9 @@ class HttpCli(object):
self.uparam = uparam
self.cookies = cookies
self.vpath = unquotep(vpath) # not query, so + means +
+ self.vpaths = (
+ self.vpath + "/" if self.trailing_slash and self.vpath else self.vpath
+ )
ok = "\x00" not in self.vpath
if ANYWIN:
@@ -687,6 +691,21 @@ class HttpCli(object):
r = ["%s=%s" % (k, quotep(zs)) if zs else k for k, zs in kv.items()]
return "?" + "&".join(r)
+ def ourlq(self) -> str:
+ skip = ("pw", "k")
+ ret = []
+ for k, v in self.ouparam.items():
+ if k in skip:
+ continue
+
+ t = "{}={}".format(quotep(k), quotep(v))
+ ret.append(t.replace(" ", "+").rstrip("="))
+
+ if not ret:
+ return ""
+
+ return "?" + "&".join(ret)
+
def redirect(
self,
vpath: str,
@@ -2025,7 +2044,9 @@ class HttpCli(object):
dst = self.args.SRS
if self.vpath:
- dst += quotep(self.vpath)
+ dst += quotep(self.vpaths)
+
+ dst += self.ourlq()
msg = self.get_pwd_cookie(pwd)
html = self.j2s("msg", h1=msg, h2='ack', redir=dst)
@@ -3090,7 +3111,7 @@ class HttpCli(object):
html = self.j2s(
"splash",
this=self,
- qvpath=quotep(self.vpath),
+ qvpath=quotep(self.vpaths) + self.ourlq(),
rvol=rvol,
wvol=wvol,
avol=avol,
@@ -3148,7 +3169,8 @@ class HttpCli(object):
t = '404 not found ┐( ´ -`)┌