diff options
| author | Fuwn <[email protected]> | 2026-05-27 09:57:05 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-05-27 10:12:41 +0000 |
| commit | 5788c408b7e8afe35926cf62daefa3d45777a67c (patch) | |
| tree | fe2130df6fffa5976e1e2b4ffd9bbe192e3e1df8 /src/cache.gleam | |
| parent | refactor: Fold images, extract pad_digits, rename xml binding (diff) | |
| download | mayu-5788c408b7e8afe35926cf62daefa3d45777a67c.tar.xz mayu-5788c408b7e8afe35926cf62daefa3d45777a67c.zip | |
fix: Reject out-of-range digits and surface data directory errors
Diffstat (limited to 'src/cache.gleam')
| -rw-r--r-- | src/cache.gleam | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/cache.gleam b/src/cache.gleam index f3baade..17fc168 100644 --- a/src/cache.gleam +++ b/src/cache.gleam @@ -55,7 +55,12 @@ fn load_theme(theme) -> Dict(Int, CachedImage) { fn parse_digit_filename(file) { case string.split(file, ".") { - [digit, _extension] -> int.parse(digit) + [digit, _extension] -> + case int.parse(digit) { + Ok(parsed_digit) if parsed_digit >= 0 && parsed_digit <= 9 -> + Ok(parsed_digit) + _ -> Error(Nil) + } _ -> Error(Nil) } } |