fix(server): check if the path is a file while serving

closes #19
This commit is contained in:
Orhun Parmaksız 2022-03-16 16:37:54 +03:00
parent ffe067f9da
commit 525129ddcb
No known key found for this signature in database
GPG key ID: F83424824B3E4B90

View file

@ -50,10 +50,12 @@ async fn serve(
}
}
}
if !path.is_file() || !path.exists() {
return Err(error::ErrorNotFound("file is not found or expired :("));
}
match paste_type {
PasteType::File | PasteType::RemoteFile | PasteType::Oneshot => {
let response = NamedFile::open(&path)
.map_err(|_| error::ErrorNotFound("file is not found or expired :("))?
let response = NamedFile::open(&path)?
.disable_content_disposition()
.set_content_type(
mime::get_mime_type(&config.paste.mime_override, file.to_string())