|
|
|
@ -63,7 +63,7 @@ class rcube_utils
|
|
|
|
|
*/
|
|
|
|
|
public static function check_email($email, $dns_check=true)
|
|
|
|
|
{
|
|
|
|
|
// Check for invalid characters
|
|
|
|
|
// Check for invalid (control) characters
|
|
|
|
|
if (preg_match('/\p{Cc}/u', $email)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -73,41 +73,28 @@ class rcube_utils
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$email_array = explode('@', $email);
|
|
|
|
|
|
|
|
|
|
// Check that there's one @ symbol
|
|
|
|
|
if (count($email_array) < 2) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$domain_part = array_pop($email_array);
|
|
|
|
|
$local_part = implode('@', $email_array);
|
|
|
|
|
|
|
|
|
|
// XXX RFC states that ".." is not allowed in a local-part
|
|
|
|
|
// of an email address, but apparently gmail allows it.
|
|
|
|
|
if(preg_match('/^\.|\.$/',$local_part)) {
|
|
|
|
|
$pos = strrpos($email, '@');
|
|
|
|
|
if (!$pos) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$local_subparts;
|
|
|
|
|
preg_match_all('/"(?:\\\\.|[^\\\\"])*"|[^\.]+/',$local_part,$local_subparts);
|
|
|
|
|
$domain_part = substr($email, $pos + 1);
|
|
|
|
|
$local_part = substr($email, 0, $pos);
|
|
|
|
|
|
|
|
|
|
foreach ($local_subparts[0] as $l) {
|
|
|
|
|
if(substr($l,0,1) == '"') {
|
|
|
|
|
// quoted-string, make sure all backslashes and quotes are
|
|
|
|
|
// escaped
|
|
|
|
|
$local_quoted = preg_replace('/\\\\(\\\\|\")/','',substr($l,1,-1));
|
|
|
|
|
if(preg_match('/\\\\|"/',$local_quoted)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// dot-atom portion, make sure there's no prohibited characters
|
|
|
|
|
if(preg_match('/[\\ ",:;<>@]/',$l)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// quoted-string, make sure all backslashes and quotes are
|
|
|
|
|
// escaped
|
|
|
|
|
if (substr($local_part,0,1) == '"') {
|
|
|
|
|
$local_quoted = preg_replace('/\\\\(\\\\|\")/','', substr($local_part, 1, -1));
|
|
|
|
|
if (preg_match('/\\\\|"/', $local_quoted)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// dot-atom portion, make sure there's no prohibited characters
|
|
|
|
|
else if (preg_match('/(^\.|\.\.|\.$)/', $local_part)
|
|
|
|
|
|| preg_match('/[\\ ",:;<>@]/', $local_part)
|
|
|
|
|
) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Validate domain part
|
|
|
|
|
if (preg_match('/^\[((IPv6:[0-9a-f:.]+)|([0-9.]+))\]$/i', $domain_part, $matches)) {
|
|
|
|
|