test(kitty): hold the remote transfer gate for t=f and t=t, not only t=s

The gate that stops a remote pane resolving a file or shm transfer had one
test and it sent `t=s`. Narrowing that gate to shm alone — so `t=f` and `t=t`
resolved on a remote pane — left the entire workspace suite green. Checked,
not assumed: 43 kitty tests and every other test in the repo passed with the
guard weakened.

That is the gate that matters. `query_reply` is the polite half; it tells a
well-behaved sender not to bother, and its own test already probes all three
media with a comment saying why. This is the half that holds when the sender
ignores the refusal, and the sender on a remote pane is the far end of an ssh
link naming a path on *this* machine. `read_file` will open whatever it is
given — bounded and regular-files-only, but given.

Now all three media are sent at a remote parser and refused, and all three at
a local parser and accepted, so the guard is pinned to refusing on locality
rather than on the medium. The failure names the path that would have been
read. Checked against both directions: narrowing the gate to shm, and
refusing regardless of locality.

No behaviour change — the guard was already right. This is the test that
would have noticed if it stopped being.
This commit is contained in:
l0ng-ai
2026-08-23 04:09:48 +08:00
parent 7368872e04
commit ba28a8224e
+37 -4
View File
@@ -1644,10 +1644,43 @@ mod tests {
fn shared_transmission_dropped_on_remote() {
// A non-local parser must never surface a file/shm transfer even if a
// misbehaving sender ignored the refusal and sent one anyway.
let b64 = BASE64.encode(b"/px-abc123");
let cmd = format!("Ga=T,f=32,t=s,s=64,v=1,i=7;{b64}");
let mut p = GraphicsParser::new();
assert_eq!(p.feed(cmd.as_bytes()), None);
//
// Every indirect medium, not only shm — the same point the query-side
// test makes, and it matters more here. `query_reply` is the polite
// half: it tells a well-behaved sender not to bother. This is the half
// that holds when the sender does it anyway, and the sender on a remote
// pane is the far end of an ssh link naming a path on *this* machine.
// Covering only `t=s` left a gate that could be narrowed to shm with
// the whole suite still green, and `t=f`/`t=t` would then read whatever
// the far side asked for.
for (id, medium, payload) in [
(7u32, "s", &b"/px-abc123"[..]),
(8, "f", &b"/etc/passwd"[..]),
(9, "t", &b"/tmp/handoff.rgba"[..]),
] {
let b64 = BASE64.encode(payload);
let cmd = format!("Ga=T,f=32,t={medium},s=64,v=1,i={id};{b64}");
let mut p = GraphicsParser::new();
assert_eq!(
p.feed(cmd.as_bytes()),
None,
"a remote pane must not surface a `t={medium}` transfer naming \
{} on this host",
String::from_utf8_lossy(payload)
);
}
// And the local counterpart still does surface all three, so the guard
// above is refusing on locality rather than on the medium.
for (id, medium) in [(17u32, "s"), (18, "f"), (19, "t")] {
let b64 = BASE64.encode(b"/px-abc123");
let cmd = format!("Ga=T,f=32,t={medium},s=64,v=1,i={id};{b64}");
let mut p = GraphicsParser::new_local(true);
assert!(
matches!(p.feed(cmd.as_bytes()), Some(Event::ImageFromMedium(_))),
"a local pane should still accept `t={medium}`"
);
}
}
#[test]