Skip to content

Commit

Permalink
feat(content): sanitize file names
Browse files Browse the repository at this point in the history
  • Loading branch information
mkroening committed Feb 8, 2025
1 parent f782f1a commit 1838b91
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion edu-sync/src/content.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{
borrow::Cow,
cmp::Ordering,
path::{Path, PathBuf},
time::SystemTime,
Expand All @@ -15,7 +16,7 @@ use tokio::{
task,
};

use crate::util::{self, PathBufExt};
use crate::util::{self, sanitize_path_component, PathBufExt};

#[derive(Debug, Clone)]
pub struct Content {
Expand Down Expand Up @@ -55,6 +56,11 @@ impl Content {
path.push_file_name_suffix(".html");
}

let file_name = path.file_name().unwrap().to_str().unwrap();
if let Cow::Owned(sanitized_file_name) = sanitize_path_component(file_name) {
path.set_file_name(sanitized_file_name);
}

path
};

Expand Down

0 comments on commit 1838b91

Please sign in to comment.