Trim form strings by default
This commit is contained in:
parent
a5470ae857
commit
423dcb6914
3 changed files with 5 additions and 9 deletions
|
@ -45,9 +45,10 @@ impl ContactForm {
|
|||
.parse()
|
||||
.context("Failed to parse the submitted id!")?;
|
||||
|
||||
// Remove an item with the given key from the map.
|
||||
// Remove a trimmed item with the given key from the map.
|
||||
let mut remove = |key| {
|
||||
map.remove(key)
|
||||
.map(|v| v.trim().to_string())
|
||||
.with_context(|| format!("{} missing in the submitted form!", key))
|
||||
};
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ impl Mailer {
|
|||
persistent_field_contents: &PersistentFieldContents,
|
||||
config: &StateConfig,
|
||||
) -> Result<()> {
|
||||
let name = persistent_field_contents.name.trim().to_string();
|
||||
let name = persistent_field_contents.name.clone();
|
||||
let subject = config.strings.message_from.clone() + &name;
|
||||
let reply_to = Mailbox::new(
|
||||
Some(name),
|
||||
|
@ -90,12 +90,7 @@ impl Mailer {
|
|||
.custom_fields
|
||||
.iter()
|
||||
.map(|field| &field.label)
|
||||
.zip(
|
||||
persistent_field_contents
|
||||
.custom
|
||||
.iter()
|
||||
.map(|content| content.trim()),
|
||||
)
|
||||
.zip(persistent_field_contents.custom.iter())
|
||||
.map(|(label, content)| format!("{label}:\n{content}\n\n\n"))
|
||||
.fold(default_fields_content, |acc, s| acc + &s);
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ pub async fn submit(
|
|||
let right_captcha_answer = captcha_solutions
|
||||
.lock()
|
||||
.unwrap()
|
||||
.check_answer(form.id, form.captcha_answer.trim());
|
||||
.check_answer(form.id, &form.captcha_answer);
|
||||
|
||||
if !right_captcha_answer {
|
||||
info!("Wrong CAPTCHA");
|
||||
|
|
Loading…
Reference in a new issue