fix #287: handle IDN email addresses

This commit is contained in:
msquare 2019-11-03 11:43:13 +01:00
parent a514ba3adc
commit dc3de33a4b
1 changed files with 7 additions and 1 deletions

View File

@ -220,12 +220,18 @@ function strip_item($item)
} }
/** /**
* Überprüft eine E-Mail-Adresse. * Validates an email address with support for IDN domain names.
* *
* @param string $email * @param string $email
* @return bool * @return bool
*/ */
function check_email($email) function check_email($email)
{ {
// Convert the domain part from idn to ascii
if(substr_count($email, '@') == 1) {
list($name, $domain) = explode('@', $email);
$domain = idn_to_ascii($domain, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46);
$email = $name . '@' . $domain;
}
return (bool)filter_var($email, FILTER_VALIDATE_EMAIL); return (bool)filter_var($email, FILTER_VALIDATE_EMAIL);
} }