add server side checks for pass and custom name

This commit is contained in:
blek 2023-10-23 13:21:50 +10:00
parent 5d8b8648cb
commit bc6f8921fb
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 24 additions and 1 deletions

View File

@ -155,9 +155,32 @@ pub async fn upload(form: FormData, state: SharedState) -> Result<Box<dyn Reply>
let params: HashMap<String, FormElement> = FormElement::from_formdata(form).await.map_err(|x| HttpReject::WarpError(x))?;
let formdata = UploadFormData::from_formdata(params.clone());
if let Some(formdata) = formdata {
let mut breaks_conf = false;
if (!state.config.files.allow_custom_names) && formdata.filename.is_some() {
breaks_conf = true;
}
if (!state.config.files.allow_pass_protection) && formdata.password.is_some() {
breaks_conf = true;
}
if breaks_conf {
let error = ErrorPage {
env: state.env,
conf: state.config,
error_text: "Attempt to set name or password when they are disabled".into(),
link: None,
link_text: None
};
return Ok(
bad_req_html(
error.render()
.map_err(|x| HttpReject::AskamaError(x))?
)
);
}
if ! formdata.tos_consent {
let error = ErrorPage {
env: state.env,