Fixed #1285 to support newer top level domain names (TLD) as well

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO
2023-03-18 16:32:14 +01:00
parent 81ffefbc65
commit 129f640421
3 changed files with 52 additions and 6 deletions

View File

@ -145,13 +145,12 @@ function checkemail($email, $domains) {
function validemail($email = '') {
if($email == '') { return 0; }
if($email == '' || !strchr($email, '@')) { return 0; }
if(preg_match("/@local$/", $email)) { return 1; }
$arr = explode("@", $email);
if(preg_match('/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,10})$/', $email)) {
return 1;
}
// This is a pretty relaxed formula making sure we have something as the local part
if(count($arr) == 2 && strlen($arr[0]) >= 1 && validdomain($arr[1])) { return 1; }
return 0;
}
@ -173,7 +172,7 @@ function checkdomain($domain, $domains) {
function validdomain($domain = '') {
if(preg_match("/@?local$/", $domain) || preg_match('/^[a-zA-Z0-9]+[a-zA-Z0-9-_\.]{0,}\.[a-zA-Z0-9]{2,10}$/', $domain)) {
if(preg_match("/@?local$/", $domain) || preg_match(DOMAIN_REGEX, $domain)) {
return 1;
}