decode urlform messages

This commit is contained in:
ed 2021-04-01 23:36:14 +02:00
parent 83fec3cca7
commit 53d3c8b28e
2 changed files with 13 additions and 3 deletions

View file

@ -306,7 +306,6 @@ roughly sorted by priority
* reduce up2k roundtrips * reduce up2k roundtrips
* start from a chunk index and just go * start from a chunk index and just go
* terminate client on bad data * terminate client on bad data
* drop onto folders
* `os.copy_file_range` for up2k cloning * `os.copy_file_range` for up2k cloning
* up2k partials ui * up2k partials ui
* support pillow-simd * support pillow-simd

View file

@ -321,8 +321,19 @@ class HttpCli(object):
elif "print" in opt: elif "print" in opt:
reader, _ = self.get_body_reader() reader, _ = self.get_body_reader()
for buf in reader: for buf in reader:
buf = buf.decode("utf-8", "replace") orig = buf.decode("utf-8", "replace")
self.log("urlform @ {}\n {}\n".format(self.vpath, buf)) 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: if "get" in opt:
return self.handle_get() return self.handle_get()