From 53d3c8b28e739bc506656e2b2130e8e4ccaf5143 Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 1 Apr 2021 23:36:14 +0200 Subject: [PATCH] decode urlform messages --- README.md | 1 - copyparty/httpcli.py | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d82e718c..f2880af0 100644 --- a/README.md +++ b/README.md @@ -306,7 +306,6 @@ roughly sorted by priority * reduce up2k roundtrips * start from a chunk index and just go * terminate client on bad data -* drop onto folders * `os.copy_file_range` for up2k cloning * up2k partials ui * support pillow-simd diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index c2face54..cf79854a 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -321,8 +321,19 @@ class HttpCli(object): elif "print" in opt: reader, _ = self.get_body_reader() for buf in reader: - buf = buf.decode("utf-8", "replace") - self.log("urlform @ {}\n {}\n".format(self.vpath, buf)) + orig = buf.decode("utf-8", "replace") + m = "urlform_raw {} @ {}\n {}\n" + self.log(m.format(len(orig), self.vpath, orig)) + try: + plain = unquote(buf.replace(b"+", b" ")) + plain = plain.decode("utf-8", "replace") + if buf.startswith(b"msg="): + plain = plain[4:] + + m = "urlform_dec {} @ {}\n {}\n" + self.log(m.format(len(plain), self.vpath, plain)) + except Exception as ex: + self.log(repr(ex)) if "get" in opt: return self.handle_get()