security: clamp alpha_num bullet expansion and sanitize filename logging (#1264)

This commit is contained in:
Dylan M. Taylor
2026-10-24 04:40:29 -04:00
committed by GitHub
parent 1e097e3edd
commit 9641817a15
3 changed files with 7 additions and 6 deletions
+3 -2
View File
@@ -41,8 +41,9 @@ pub fn poll(inbox: &Inbox, app: &mut SlideApp, ctx: &egui::Context) {
Event::Open(paths) => {
for p in paths.iter().filter_map(|p| p.to_str()) {
if let Err(e) = app.open_path(p) {
log::error!("{p}: {e}");
app.set_status(format!("Couldn't open {p}: {e}"));
let safe_p = p.replace(['\r', '\n'], " ");
log::error!("{safe_p}: {e}");
app.set_status(format!("Couldn't open {safe_p}: {e}"));
}
}
}
+3 -4
View File
@@ -572,11 +572,10 @@ fn alpha_num(n: u32, upper: bool) -> String {
if n == 0 {
return String::new();
}
let mut n = n - 1;
let n = n - 1;
let c = (b'a' + (n % 26) as u8) as char;
let reps = n / 26 + 1;
n = reps;
let s: String = std::iter::repeat_n(c, n as usize).collect();
let reps = (n / 26 + 1).min(50);
let s: String = std::iter::repeat_n(c, reps as usize).collect();
if upper { s.to_uppercase() } else { s }
}
+1
View File
@@ -394,6 +394,7 @@ fn autonum_formats() {
assert_eq!(autonum("alphaLcParenR", 2), "b)");
assert_eq!(autonum("arabicParenBoth", 1), "(1)");
assert_eq!(autonum("alphaUcPeriod", 27), "AA.");
assert_eq!(autonum("alphaUcPeriod", u32::MAX).len(), 51); // 50 letters + '.'
}
#[test]