Trimming emailaddress from user

This commit is contained in:
Dennis Potter 2019-10-23 00:08:29 +02:00
parent 415d759fb6
commit 4bf30d1fca
Signed by: Dennis
GPG Key ID: 186A8AD440942BAF

View File

@ -103,7 +103,7 @@ fn validate_name(name: &String) -> bool {
fn validate_email(email: &String) -> bool {
// Check if the emailaddress is valid
// This function is not completely correct: emailregex.com
Regex::new(r"^[a-zA-Z0-9\.\-_]+@[a-zA-Z0-9\-\.]+\.[a-zA-Z]+$").unwrap().is_match(email)
Regex::new(r"^[a-zA-Z0-9\.\-_]+@[a-zA-Z0-9\-\.]+\.[a-zA-Z]+$").unwrap().is_match(email.trim())
}
fn validate_guests(guests: &u8) -> bool {
@ -247,7 +247,7 @@ fn submit_task (host: HostHeader,
if x.guests > 0 {
// Send email about attendaning wedding
result = send_email(&x.name,
&x.email,
&x.email.trim().to_string(),
&language_strings.attending_email.subject,
&strfmt(&language_strings.attending_email.message, &vars).unwrap(),
Some(&language_strings.attending_email.attachment), //attachment
@ -256,7 +256,7 @@ fn submit_task (host: HostHeader,
} else {
// Send email about not attending wedding
result = send_email(&x.name,
&x.email,
&x.email.trim().to_string(),
&language_strings.not_attending_email.subject,
&strfmt(&language_strings.not_attending_email.message, &vars).unwrap(),
None, // No attachment