use shlex to parse/ escape stings for POSIX shells - #347
Conversation
…tests Problem: the shlex-based fix for serokell#130/serokell#343 duplicated the same try_join/unwrap_or call at both NIX_SSHOPTS call sites in push.rs, and shipped without any regression test covering either the ssh_opts parsing side (lib.rs) or the ssh_opts joining side (push.rs). Solution: extract parse_ssh_opts (lib.rs) and join_ssh_opts (push.rs) as named, testable functions, and add unit tests reproducing the broken tokenization from serokell#130 and the broken NIX_SSHOPTS join from serokell#343 against the old naive space-split/space-join behavior.
a7f13e5 to
2ba4c07
Compare
|
Thank you for your work on this. I've rebased your branch (and resolved conflicts) and added some tests. One note: I don't think this fixes #343. That failure happens during the direct SSH activation call, where each CI is currently red. I didn't delve into it myself but I had Claude check. So please don't take its feedback at face value, just something that perhaps could help unblock this PR:
That's a problem because Nix's It's not limited to ProxyCommand-style values either. Since shlex quotes almost anything containing A quoting function that only wraps a value in quotes when it actually contains whitespace, instead of delegating to shlex's more conservative default, would fix the space-in-a-value case on Nix 2.26+ without changing anything for values that already worked, on any Nix version. Worth noting: even with that fix, a value with an embedded space still won't work on Nix below 2.26, since that Nix has no way to receive it correctly at all. That's a Nix-side limitation, not something fixable from here. I don't have the bandwidth to implement that fix as part of this review, so flagging it here. |
Use the shlex crate to split/ parse the
ssh_optsinstead of just splitting by' '.If shlex fails to parse/ join, we fall back to the old way.
Fixes #130. Might fix #343.