mirror of
https://github.com/9001/copyparty.git
synced 2026-03-30 12:02:58 +10:00
webdav: fix depth:0 in rootless vfs;
also safeguards against potential issues with invalid paths if the api is used incorrectly from a plugin
This commit is contained in:
@@ -1551,6 +1551,7 @@ class HttpCli(object):
|
||||
if xtag is not None:
|
||||
props = set([y.tag.split("}")[-1] for y in xtag])
|
||||
# assume <allprop/> otherwise; nobody ever gonna <propname/>
|
||||
self.hint = ""
|
||||
|
||||
zi = int(time.time())
|
||||
vst = os.stat_result((16877, -1, -1, 1, 1000, 1000, 8, zi, zi, zi))
|
||||
@@ -1560,7 +1561,9 @@ class HttpCli(object):
|
||||
except OSError as ex:
|
||||
if ex.errno not in (errno.ENOENT, errno.ENOTDIR):
|
||||
raise
|
||||
raise Pebkac(404)
|
||||
if tap:
|
||||
raise Pebkac(404)
|
||||
st = vst
|
||||
|
||||
topdir = {"vp": "", "st": st}
|
||||
fgen: Iterable[dict[str, Any]] = []
|
||||
@@ -1600,6 +1603,9 @@ class HttpCli(object):
|
||||
)
|
||||
|
||||
elif depth == "0" or not stat.S_ISDIR(st.st_mode):
|
||||
if depth == "0" and not self.vpath and not vn.realpath:
|
||||
# rootless server; give dummy listing
|
||||
self.can_read = True
|
||||
# propfind on a file; return as topdir
|
||||
if not self.can_read and not self.can_get:
|
||||
self.log("inaccessible: %r" % ("/" + self.vpath,))
|
||||
@@ -1632,7 +1638,11 @@ class HttpCli(object):
|
||||
self.log("inaccessible: %r" % ("/" + self.vpath,))
|
||||
raise Pebkac(401, "authenticate")
|
||||
|
||||
zi = vn.flags["du_iwho"] if "quota-available-bytes" in props else 0
|
||||
zi = (
|
||||
vn.flags["du_iwho"]
|
||||
if vn.realpath and "quota-available-bytes" in props
|
||||
else 0
|
||||
)
|
||||
if zi and (
|
||||
zi == 9
|
||||
or (zi == 7 and self.uname != "*")
|
||||
@@ -1767,6 +1777,7 @@ class HttpCli(object):
|
||||
assert xprop # !rm
|
||||
for ze in xprop:
|
||||
ze.clear()
|
||||
self.hint = ""
|
||||
|
||||
txt = """<multistatus xmlns="DAV:"><response><propstat><status>HTTP/1.1 403 Forbidden</status></propstat></response></multistatus>"""
|
||||
xroot = parse_xml(txt)
|
||||
@@ -1824,6 +1835,7 @@ class HttpCli(object):
|
||||
ET.register_namespace("D", "DAV:")
|
||||
lk = parse_xml(txt)
|
||||
assert lk.tag == "{DAV:}lockinfo"
|
||||
self.hint = ""
|
||||
|
||||
token = str(uuid.uuid4())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user