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:
parent
e3791aebcb
commit
da453f0b4b
2 changed files with 100 additions and 9 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue