mirror of
https://github.com/9001/copyparty.git
synced 2025-10-30 12:12:20 -06:00
xm-hooks: list of selected files; closes #921
previously, `xm` hooks would be called with the `txt` property containing the url-decoded message now, a new property `body` contains the original unmodified message, to avoid any ambiguity caused by url-decoding if any files are selected, the list of files is appended to the `txt` field as lines, and as `sel` url-parameters in `body` Co-authored-by: Carson Coder <carson@carsoncoder.com>
This commit is contained in:
parent
d099e5e84e
commit
6c024dbf80
|
|
@ -511,7 +511,7 @@ class FtpHandler(FTPHandler):
|
|||
0,
|
||||
self.cli_ip,
|
||||
time.time(),
|
||||
"",
|
||||
None,
|
||||
)
|
||||
t = hr.get("rejectmsg") or ""
|
||||
if t or not hr:
|
||||
|
|
|
|||
|
|
@ -2144,7 +2144,7 @@ class HttpCli(object):
|
|||
t = "urlform_raw %d @ %r\n %r\n"
|
||||
self.log(t % (len(orig), "/" + self.vpath, orig))
|
||||
try:
|
||||
zb = unquote(buf.replace(b"+", b" "))
|
||||
zb = unquote(buf.replace(b"+", b" ").replace(b"&", b"\n"))
|
||||
plain = zb.decode("utf-8", "replace")
|
||||
if buf.startswith(b"msg="):
|
||||
plain = plain[4:]
|
||||
|
|
@ -2165,7 +2165,7 @@ class HttpCli(object):
|
|||
len(buf),
|
||||
self.ip,
|
||||
time.time(),
|
||||
plain,
|
||||
[plain, orig],
|
||||
)
|
||||
|
||||
t = "urlform_dec %d @ %r\n %r\n"
|
||||
|
|
@ -2326,7 +2326,7 @@ class HttpCli(object):
|
|||
remains,
|
||||
self.ip,
|
||||
at,
|
||||
"",
|
||||
None,
|
||||
)
|
||||
t = hr.get("rejectmsg") or ""
|
||||
if t or not hr:
|
||||
|
|
@ -2461,7 +2461,7 @@ class HttpCli(object):
|
|||
post_sz,
|
||||
self.ip,
|
||||
at,
|
||||
"",
|
||||
None,
|
||||
)
|
||||
t = hr.get("rejectmsg") or ""
|
||||
if t or not hr:
|
||||
|
|
@ -3299,7 +3299,7 @@ class HttpCli(object):
|
|||
0,
|
||||
self.ip,
|
||||
time.time(),
|
||||
"",
|
||||
None,
|
||||
)
|
||||
t = hr.get("rejectmsg") or ""
|
||||
if t or not hr:
|
||||
|
|
@ -3471,7 +3471,7 @@ class HttpCli(object):
|
|||
0,
|
||||
self.ip,
|
||||
at,
|
||||
"",
|
||||
None,
|
||||
)
|
||||
t = hr.get("rejectmsg") or ""
|
||||
if t or not hr:
|
||||
|
|
@ -3578,7 +3578,7 @@ class HttpCli(object):
|
|||
sz,
|
||||
self.ip,
|
||||
at,
|
||||
"",
|
||||
None,
|
||||
)
|
||||
t = hr.get("rejectmsg") or ""
|
||||
if t or not hr:
|
||||
|
|
@ -3891,7 +3891,7 @@ class HttpCli(object):
|
|||
0,
|
||||
self.ip,
|
||||
time.time(),
|
||||
"",
|
||||
None,
|
||||
)
|
||||
t = hr.get("rejectmsg") or ""
|
||||
if t or not hr:
|
||||
|
|
@ -3939,7 +3939,7 @@ class HttpCli(object):
|
|||
sz,
|
||||
self.ip,
|
||||
new_lastmod,
|
||||
"",
|
||||
None,
|
||||
)
|
||||
t = hr.get("rejectmsg") or ""
|
||||
if t or not hr:
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ class SMB(object):
|
|||
0,
|
||||
"1.7.6.2",
|
||||
time.time(),
|
||||
"",
|
||||
None,
|
||||
)
|
||||
t = hr.get("rejectmsg") or ""
|
||||
if t or not hr:
|
||||
|
|
|
|||
|
|
@ -379,7 +379,7 @@ class Tftpd(object):
|
|||
0,
|
||||
"8.3.8.7",
|
||||
time.time(),
|
||||
"",
|
||||
None,
|
||||
)
|
||||
t = hr.get("rejectmsg") or ""
|
||||
if t or not hr:
|
||||
|
|
|
|||
|
|
@ -3304,7 +3304,7 @@ class Up2k(object):
|
|||
job["size"],
|
||||
job["addr"],
|
||||
job["at"],
|
||||
"",
|
||||
None,
|
||||
)
|
||||
t = hr.get("rejectmsg") or ""
|
||||
if t or not hr:
|
||||
|
|
@ -4000,7 +4000,7 @@ class Up2k(object):
|
|||
sz,
|
||||
ip,
|
||||
at or time.time(),
|
||||
"",
|
||||
None,
|
||||
)
|
||||
t = hr.get("rejectmsg") or ""
|
||||
if t or not hr:
|
||||
|
|
@ -4236,7 +4236,7 @@ class Up2k(object):
|
|||
st.st_size,
|
||||
ip,
|
||||
time.time(),
|
||||
"",
|
||||
None,
|
||||
):
|
||||
t = "delete blocked by xbd server config: %r"
|
||||
self.log(t % (abspath,), 1)
|
||||
|
|
@ -4276,7 +4276,7 @@ class Up2k(object):
|
|||
st.st_size,
|
||||
ip,
|
||||
time.time(),
|
||||
"",
|
||||
None,
|
||||
)
|
||||
|
||||
if is_dir:
|
||||
|
|
@ -4404,7 +4404,7 @@ class Up2k(object):
|
|||
fsize,
|
||||
ip,
|
||||
time.time(),
|
||||
"",
|
||||
None,
|
||||
):
|
||||
t = "copy blocked by xbr server config: %r" % (svp,)
|
||||
self.log(t, 1)
|
||||
|
|
@ -4505,7 +4505,7 @@ class Up2k(object):
|
|||
fsize,
|
||||
ip,
|
||||
time.time(),
|
||||
"",
|
||||
None,
|
||||
)
|
||||
|
||||
return "k"
|
||||
|
|
@ -4656,7 +4656,7 @@ class Up2k(object):
|
|||
fsize,
|
||||
ip,
|
||||
time.time(),
|
||||
"",
|
||||
None,
|
||||
):
|
||||
t = "move blocked by xbr server config: %r" % (svp,)
|
||||
self.log(t, 1)
|
||||
|
|
@ -4696,7 +4696,7 @@ class Up2k(object):
|
|||
fsize,
|
||||
ip,
|
||||
time.time(),
|
||||
"",
|
||||
None,
|
||||
)
|
||||
|
||||
return "k"
|
||||
|
|
@ -4816,7 +4816,7 @@ class Up2k(object):
|
|||
fsize,
|
||||
ip,
|
||||
time.time(),
|
||||
"",
|
||||
None,
|
||||
)
|
||||
|
||||
return "k"
|
||||
|
|
@ -5154,7 +5154,7 @@ class Up2k(object):
|
|||
job["size"],
|
||||
job["addr"],
|
||||
job["t0"],
|
||||
"",
|
||||
None,
|
||||
)
|
||||
t = hr.get("rejectmsg") or ""
|
||||
if t or not hr:
|
||||
|
|
|
|||
|
|
@ -3885,7 +3885,7 @@ def _runhook(
|
|||
sz: int,
|
||||
ip: str,
|
||||
at: float,
|
||||
txt: str,
|
||||
txt: Optional[list[str]],
|
||||
) -> dict[str, Any]:
|
||||
ret = {"rc": 0}
|
||||
areq, chk, imp, fork, sin, jtxt, wait, sp_ka, acmd = _parsehook(log, cmd)
|
||||
|
|
@ -3908,15 +3908,17 @@ def _runhook(
|
|||
"user": uname,
|
||||
"perms": perms,
|
||||
"src": src,
|
||||
"txt": txt,
|
||||
}
|
||||
if txt:
|
||||
ja["txt"] = txt[0]
|
||||
ja["body"] = txt[1]
|
||||
if imp:
|
||||
ja["log"] = log
|
||||
mod = loadpy(acmd[0], False)
|
||||
return mod.main(ja)
|
||||
arg = json.dumps(ja)
|
||||
else:
|
||||
arg = txt or ap
|
||||
arg = txt[0] if txt else ap
|
||||
|
||||
if acmd[0].startswith("zmq:"):
|
||||
zi, zs = _zmq_hook(log, verbose, src, acmd[0][4:].lower(), arg, wait, sp_ka)
|
||||
|
|
@ -3979,7 +3981,7 @@ def runhook(
|
|||
sz: int,
|
||||
ip: str,
|
||||
at: float,
|
||||
txt: str,
|
||||
txt: Optional[list[str]],
|
||||
) -> dict[str, Any]:
|
||||
assert broker or up2k # !rm
|
||||
args = (broker or up2k).args # type: ignore
|
||||
|
|
|
|||
|
|
@ -8613,9 +8613,14 @@ var msel = (function () {
|
|||
sf.textContent = 'sending...';
|
||||
|
||||
var xhr = new XHR(),
|
||||
sel = msel.getsel(),
|
||||
msg = uricom_enc(tb.value),
|
||||
ct = 'application/x-www-form-urlencoded;charset=UTF-8';
|
||||
|
||||
xhr.msg = tb.value;
|
||||
for (var a = 0; a < sel.length; a++)
|
||||
msg += "&sel=" + sel[a].vp.split('/').pop();
|
||||
|
||||
xhr.msg = msg;
|
||||
xhr.open('POST', get_evpath(), true);
|
||||
xhr.responseType = 'text';
|
||||
xhr.onload = xhr.onerror = cb;
|
||||
|
|
@ -8623,7 +8628,7 @@ var msel = (function () {
|
|||
if (xhr.overrideMimeType)
|
||||
xhr.overrideMimeType('Content-Type', ct);
|
||||
|
||||
xhr.send('msg=' + uricom_enc(xhr.msg));
|
||||
xhr.send('msg=' + xhr.msg);
|
||||
return false;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue