diff --git a/modules/contact.module b/modules/contact.module index 02798a8e4cedf30d60f5b9d9f0ec157886667585..70d680504f5dc707bf3456624298dfc87fc0dc52 100644 --- a/modules/contact.module +++ b/modules/contact.module @@ -188,6 +188,14 @@ function contact_admin_edit($cid = NULL) { if (empty($edit['recipients'])) { form_set_error('recipients', t('You must enter one or more recipients.')); } + else { + $recipients = split(',', $edit['recipients']); + foreach($recipients as $recipient) { + if (!valid_email_address(trim($recipient))) { + form_set_error('recipients',t('%recipient is an invalid e-mail address.', array('%recipient' => theme('placeholder', $recipient)))); + } + } + } if (!form_get_errors()) { db_query("DELETE FROM {contact} WHERE cid = %d", $cid); @@ -298,6 +306,10 @@ function contact_mail_page_validate($form_id, &$form) { else { form_set_error('category', t('You must select a valid category.')); } + + if (!valid_email_address($form['mail'])) { + form_set_error('mail', t('You must enter a valid e-mail address.')); + } } } diff --git a/modules/contact/contact.module b/modules/contact/contact.module index 02798a8e4cedf30d60f5b9d9f0ec157886667585..70d680504f5dc707bf3456624298dfc87fc0dc52 100644 --- a/modules/contact/contact.module +++ b/modules/contact/contact.module @@ -188,6 +188,14 @@ function contact_admin_edit($cid = NULL) { if (empty($edit['recipients'])) { form_set_error('recipients', t('You must enter one or more recipients.')); } + else { + $recipients = split(',', $edit['recipients']); + foreach($recipients as $recipient) { + if (!valid_email_address(trim($recipient))) { + form_set_error('recipients',t('%recipient is an invalid e-mail address.', array('%recipient' => theme('placeholder', $recipient)))); + } + } + } if (!form_get_errors()) { db_query("DELETE FROM {contact} WHERE cid = %d", $cid); @@ -298,6 +306,10 @@ function contact_mail_page_validate($form_id, &$form) { else { form_set_error('category', t('You must select a valid category.')); } + + if (!valid_email_address($form['mail'])) { + form_set_error('mail', t('You must enter a valid e-mail address.')); + } } }