mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
disallow uploading logues
This commit is contained in:
parent
c30dc0b546
commit
26e18ae800
|
@ -741,7 +741,9 @@ class HttpCli(object):
|
|||
|
||||
if p_file and not nullwrite:
|
||||
fdir = os.path.join(vfs.realpath, rem)
|
||||
fname = sanitize_fn(p_file)
|
||||
fname = sanitize_fn(
|
||||
p_file, bad=[".prologue.html", ".epilogue.html"]
|
||||
)
|
||||
|
||||
if not os.path.isdir(fsenc(fdir)):
|
||||
raise Pebkac(404, "that folder does not exist")
|
||||
|
|
|
@ -87,7 +87,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, ok="/")
|
||||
bfn = fn.encode("utf-8" if utf8 else "cp437", "replace").replace(b"?", b"_")
|
||||
|
||||
z64_len = len(z64v) * 8 + 4 if z64v else 0
|
||||
|
|
|
@ -891,7 +891,7 @@ class Up2k(object):
|
|||
if cj["ptop"] not in self.registry:
|
||||
raise Pebkac(410, "location unavailable")
|
||||
|
||||
cj["name"] = sanitize_fn(cj["name"])
|
||||
cj["name"] = sanitize_fn(cj["name"], bad=[".prologue.html", ".epilogue.html"])
|
||||
cj["poke"] = time.time()
|
||||
wark = self._get_wark(cj)
|
||||
now = time.time()
|
||||
|
|
|
@ -576,7 +576,7 @@ def undot(path):
|
|||
return "/".join(ret)
|
||||
|
||||
|
||||
def sanitize_fn(fn, ok=""):
|
||||
def sanitize_fn(fn, ok="", bad=[]):
|
||||
if "/" not in ok:
|
||||
fn = fn.replace("\\", "/").split("/")[-1]
|
||||
|
||||
|
@ -595,12 +595,12 @@ def sanitize_fn(fn, ok=""):
|
|||
for bad, good in [x for x in remap if x[0] not in ok]:
|
||||
fn = fn.replace(bad, good)
|
||||
|
||||
bad = ["con", "prn", "aux", "nul"]
|
||||
bad.extend(["con", "prn", "aux", "nul"])
|
||||
for n in range(1, 10):
|
||||
bad += "com{0} lpt{0}".format(n).split(" ")
|
||||
|
||||
if fn.lower() in bad:
|
||||
fn = "_" + fn
|
||||
if fn.lower() in bad:
|
||||
fn = "_" + fn
|
||||
|
||||
return fn.strip()
|
||||
|
||||
|
|
Loading…
Reference in a new issue