diff --git a/copyparty/__version__.py b/copyparty/__version__.py index fde589f0..feebafd4 100644 --- a/copyparty/__version__.py +++ b/copyparty/__version__.py @@ -1,6 +1,6 @@ # coding: utf-8 -VERSION = (0, 10, 0) +VERSION = (0, 10, 1) CODENAME = "zip it" BUILD_DT = (2021, 3, 27) diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index a8db0502..b20b98a1 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -1090,15 +1090,17 @@ class HttpCli(object): ) bascii = unicode(string.ascii_letters + string.digits).encode("utf-8") - chcon = ord if PY2 else int - ufn = b"".join( - [ + ufn = fn.encode("utf-8", "xmlcharrefreplace") + if PY2: + ufn = [unicode(x) if x in bascii else "%{:02x}".format(ord(x)) for x in ufn] + else: + ufn = [ chr(x).encode("utf-8") if x in bascii - else "%{:02x}".format(chcon(x)).encode("ascii") - for x in fn.encode("utf-8", "xmlcharrefreplace") + else "%{:02x}".format(x).encode("ascii") + for x in ufn ] - ).decode("ascii") + ufn = b"".join(ufn).decode("ascii") cdis = "attachment; filename=\"{}.{}\"; filename*=UTF-8''{}.{}" cdis = cdis.format(afn, fmt, ufn, fmt) diff --git a/copyparty/szip.py b/copyparty/szip.py index 35bc0347..99bc74ec 100644 --- a/copyparty/szip.py +++ b/copyparty/szip.py @@ -85,7 +85,7 @@ def gen_hdr(h_pos, fn, sz, lastmod, utf8, crc32, pre_crc): ret += struct.pack("", ">"], [":", ":"], @@ -590,7 +591,7 @@ def sanitize_fn(fn): ["|", "|"], ["?", "?"], ["*", "*"], - ]: + ] if x[0] not in ok]: fn = fn.replace(bad, good) bad = ["con", "prn", "aux", "nul"]