Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.440 diff -u -F^f -r1.440 common.inc --- includes/common.inc 7 May 2005 01:48:06 -0000 1.440 +++ includes/common.inc 10 May 2005 20:52:52 -0000 @@ -587,12 +587,23 @@ function check_plain($text) { * 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}'; + /* We don't support folding whitespace here. */ + $cfws = ""; + $atext = "[-a-zA-Z0-9!#$%&'*+\\/=?^_`{|}~]"; + $atom = "(?:$cfws)?(?:$atext)+(?:$cfws)?"; + $dot_atom_text = "(?:$atext)+(?:\\.(?:$atext)+)*"; + $dot_atom = "(?:$cfws)?$dot_atom_text(?:$cfws)?"; + /* We don't support quoted strings here. */ + $quoted_string = ""; + $domain_literal = '\[[^\[\]\\]*\]'; + + $local_part = "(?:$dot_atom|$quoted_string)"; + $domain = "(?:$dot_atom|$domain_literal)"; + + $addr_spec = "$local_part@$domain"; + + return preg_match("/^$addr_spec\$/", $mail); - return preg_match("/^$user@($domain|(\[($ipv4|$ipv6)\]))$/", $mail); } /**