More fixes for unicode-of-bytes bugs.

This commit is contained in:
Itamar Turner-Trauring 2021-02-11 13:28:09 -05:00
parent eebeca31f5
commit 9f1ca2ab6f
3 changed files with 9 additions and 6 deletions

View File

@ -156,7 +156,10 @@ class ResultsBase(object):
shares_on_server.add(s, shareid)
shareid_s = ""
if i == 0:
shareid_s = str(shareid)
if isinstance(shareid, bytes):
shareid_s = str(shareid, "utf-8")
else:
shareid_s = str(shareid)
d = tags.tr(tags.td(shareid_s),
tags.td(tags.div(s.get_nickname(), class_="nickname"),
tags.div(tags.tt(s.get_name()), class_="nodeid")))
@ -207,12 +210,12 @@ class ResultsBase(object):
return [html.escape(w) for w in s]
def _render_si_link(self, req, storage_index):
si_s = base32.b2a(storage_index)
ophandle = req.prepath[-1]
si_s = str(base32.b2a(storage_index), "utf-8")
ophandle = str(req.prepath[-1], "utf-8")
target = "%s/operations/%s/%s" % (get_root(req), ophandle, si_s)
output = get_arg(req, "output")
if output:
target = target + "?output=%s" % output
target = target + "?output=" + str(output, "utf-8")
return tags.a(si_s, href=target)

View File

@ -148,7 +148,7 @@ def get_format(req, default="CHK"):
elif arg.upper() == b"MDMF":
return "MDMF"
else:
raise WebError("Unknown format: %s, I know CHK, SDMF, MDMF" % arg,
raise WebError("Unknown format: %s, I know CHK, SDMF, MDMF" % str(arg, "ascii"),
http.BAD_REQUEST)
def get_mutable_type(file_format): # accepts result of get_format()

View File

@ -1194,7 +1194,7 @@ class ManifestElement(ReloadableMonitorElement):
si = self.monitor.origin_si
if not si:
return "<LIT>"
return base32.b2a(si)[:6]
return unicode(base32.b2a(si)[:6], "utf-8")
@renderer
def title(self, req, tag):