Commit ae31a4ab authored by Dries's avatar Dries

- Patch #308138 by mfer, Dave Reid: replace valid_email_address with...

- Patch #308138 by mfer, Dave Reid: replace valid_email_address with filter_var and FILTER_VALIDATE_EMAIL.
parent 2f3146f0
......@@ -866,12 +866,7 @@ function t($string, $args = array(), $langcode = NULL) {
* TRUE if the address is in a valid format.
*/
function valid_email_address($mail) {
$user = '[a-zA-Z0-9_\-\.\+\^!#\$%&*+\/\=\?\`\|\{\}~\']+';
$domain = '(?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.?)+';
$ipv4 = '[0-9]{1,3}(\.[0-9]{1,3}){3}';
$ipv6 = '[0-9a-fA-F]{1,4}(\:[0-9a-fA-F]{1,4}){7}';
return (bool)preg_match("/^$user@($domain|(\[($ipv4|$ipv6)\]))$/", $mail);
return (bool)filter_var($mail, FILTER_VALIDATE_EMAIL);
}
/**
......
......@@ -45,7 +45,7 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
// Add categories.
// Test invalid recipients.
$invalid_recipients = array('invalid', 'invalid@', /*'invalid@site', 'invalid@site.',*/ '@site.', '@site.com');
$invalid_recipients = array('invalid', 'invalid@', 'invalid@site', 'invalid@site.', '@site.', '@site.com');
foreach ($invalid_recipients as $invalid_recipient) {
$this->addCategory($this->randomName(16), $invalid_recipient, '', FALSE);
$this->assertRaw(t('%recipient is an invalid e-mail address.', array('%recipient' => $invalid_recipient)), t('Caught invalid recipient (' . $invalid_recipient . ').'));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment