mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 09:22:31 -06:00
v0.10.1
This commit is contained in:
parent
3b354447b0
commit
b12131e91c
|
@ -1,6 +1,6 @@
|
|||
# coding: utf-8
|
||||
|
||||
VERSION = (0, 10, 0)
|
||||
VERSION = (0, 10, 1)
|
||||
CODENAME = "zip it"
|
||||
BUILD_DT = (2021, 3, 27)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -85,7 +85,7 @@ def gen_hdr(h_pos, fn, sz, lastmod, utf8, crc32, pre_crc):
|
|||
ret += struct.pack("<LL", vsz, vsz)
|
||||
|
||||
# windows support (the "?" replace below too)
|
||||
fn = sanitize_fn(fn)
|
||||
fn = sanitize_fn(fn, "/")
|
||||
bfn = fn.encode("utf-8" if utf8 else "cp437", "replace").replace(b"?", b"_")
|
||||
|
||||
z64_len = len(z64v) * 8 + 4 if z64v else 0
|
||||
|
|
|
@ -576,11 +576,12 @@ def undot(path):
|
|||
return "/".join(ret)
|
||||
|
||||
|
||||
def sanitize_fn(fn):
|
||||
fn = fn.replace("\\", "/").split("/")[-1]
|
||||
def sanitize_fn(fn, ok=""):
|
||||
if "/" not in ok:
|
||||
fn = fn.replace("\\", "/").split("/")[-1]
|
||||
|
||||
if WINDOWS:
|
||||
for bad, good in [
|
||||
for bad, good in [x for x in [
|
||||
["<", "<"],
|
||||
[">", ">"],
|
||||
[":", ":"],
|
||||
|
@ -590,7 +591,7 @@ def sanitize_fn(fn):
|
|||
["|", "|"],
|
||||
["?", "?"],
|
||||
["*", "*"],
|
||||
]:
|
||||
] if x[0] not in ok]:
|
||||
fn = fn.replace(bad, good)
|
||||
|
||||
bad = ["con", "prn", "aux", "nul"]
|
||||
|
|
Loading…
Reference in a new issue