validate path is now handled by sanitize

main
Zynh0722 2023-04-12 01:28:51 -07:00
parent d63b8e2820
commit 4816b5a6c7
1 changed files with 0 additions and 17 deletions

View File

@ -87,10 +87,6 @@ async fn upload_to_zip(mut body: Multipart) -> Result<Redirect, (StatusCode, Str
_ => continue, _ => continue,
}; };
if !path_is_valid(&file_name) {
return Err((StatusCode::BAD_REQUEST, "Invalid Filename >:(".to_owned()));
}
tracing::debug!("Downloading to Zip: {file_name:?}"); tracing::debug!("Downloading to Zip: {file_name:?}");
let stream = field; let stream = field;
@ -121,19 +117,6 @@ async fn upload_to_zip(mut body: Multipart) -> Result<Redirect, (StatusCode, Str
Ok(Redirect::to(&format!("/link.html?link={}.zip", cache_name))) Ok(Redirect::to(&format!("/link.html?link={}.zip", cache_name)))
} }
#[inline]
fn path_is_valid(path: &str) -> bool {
let mut components = Path::new(path).components().peekable();
if let Some(first) = components.peek() {
if !matches!(first, std::path::Component::Normal(_)) {
return false;
}
}
components.count() == 1
}
#[inline] #[inline]
async fn make_dir<T>(name: T) -> io::Result<()> async fn make_dir<T>(name: T) -> io::Result<()>
where where