Repository navigation
fix(find/git): avoid UTF-8 mid-char byte-slice panics - #3435
mohammedelkarsh wants to merge 1 commit into
Conversation
Truncate find path display with floor_char_boundary, and parse git commit output via strip_prefix so non-ASCII / malformed first lines cannot panic. Fixes rtk-ai#3415
Overlapping git.rs/find_cmd.rs sites resolved in favour of rtk-ai#3435, which applies the same strip_prefix fix; rtk-ai#3451 contributes the remaining four sites (gain, prisma, display_helpers, utils).
|
Thanks for chasing both panics and for pinning them with tests. Issue #3415 is closed as completed: parse_commit_output was rewritten in #2717 (merged 2026-08-13) so both bracket indices come from str::find and can never land mid-character, and it now carries eleven tests including the exact inputs from the report, among them "] stray [main abc1234def]" and the multibyte prefixes. That version also keeps the short hash when git prints hook output ahead of its summary, a case the strip_prefix approach here would report as a bare "ok". The find side was rewritten in #3603 (merged 2026-08-26): the directory label now truncates at 50 characters rather than 50 bytes, so the mid-character slice is gone, and there is an end-to-end test for a long non-ASCII directory name. What develop still lacks is a unit test pinning the shape of that truncated label, as the issue reporter noted, and a small test there would be welcome. Please comment or reopen if something was missed. |
Summary
rtk finddisplay truncation so paths longer than 50 bytes truncate on char boundaries (Thai/CJK paths no longer panic).parse_commit_outputto require a leading[viastrip_prefixinstead of&line[1..], so hook noise / multibyte first lines cannot panic.rtk findpanics on a non-ASCII directory path >50 bytes, andrtk git commitpanics when the first output line does not start with[#3415.Fixes #3415
Test plan
cargo test --bin rtk truncate_path_displaycargo test --bin rtk test_parse_commit_outputcargo fmt --allcargo clippy --bin rtk --all-targets -- -D warnings