(7ac39e3) Fix byte-slice panics in id shortening and date formatting

Three places sliced strings by byte offset on values that come from a
filename or a file field, neither of which is validated.

The disambiguation list took &short_id[..7], so two tickets whose names
were shorter than that aborted the process while printing the options.
collect_ticket_items guarded on length but still cut at byte 7, so a
multibyte character straddling the cut panicked. format_created_at read
four fixed offsets after a length check that a multibyte value passes.

Add short_id, which counts characters, and use it in both display paths.
Parse the timestamp with chrono instead of slicing, dropping the column
when the value will not parse. The format string it writes and the one it
reads are now the same constant, so they cannot drift.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ansho Rei
2026-08-20 13:56:10 +02:00
co-authored by Claude Opus 5
parent 8ff64614fc
commit c675da1d2a
4 changed files with 173 additions and 23 deletions
+2 -2
View File
@@ -174,7 +174,7 @@ pub fn cmd_add(
},
due.as_deref().unwrap_or("_Not set_"),
owner.as_deref().unwrap_or("_Not set_"),
Local::now().format("%Y-%m-%d %H:%M:%S"),
Local::now().format(TIMESTAMP_FORMAT),
);
body.push('\n');
@@ -390,7 +390,7 @@ pub fn cmd_comment(
",
body,
author,
Local::now().format("%Y-%m-%d %H:%M:%S")
Local::now().format(TIMESTAMP_FORMAT)
);
fs::write(&filepath, comment_content)?;