fix: prevent panics from byte-level string slicing on multi-byte UTF-8

Uses floor_char_boundary() instead of direct byte indexing to prevent panics when slicing strings containing multi-byte UTF-8 characters.
This commit is contained in:
Argenis 2026-02-15 08:06:04 -05:00 committed by GitHub
parent e3791aebcb
commit da453f0b4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 100 additions and 9 deletions

View file

@ -326,7 +326,7 @@ fn date_prefix(filename: &str) -> Option<NaiveDate> {
if filename.len() < 10 {
return None;
}
NaiveDate::parse_from_str(&filename[..10], "%Y-%m-%d").ok()
NaiveDate::parse_from_str(&filename[..filename.floor_char_boundary(10)], "%Y-%m-%d").ok()
}
fn is_older_than(path: &Path, cutoff: SystemTime) -> bool {