Add unit tests for valid email function.

This commit is contained in:
ken restivo
2015-11-08 14:37:48 -08:00
parent 2536dc39b5
commit 9c240de303
2 changed files with 37 additions and 4 deletions

View File

@@ -872,15 +872,17 @@ function searchbox($s,$id='search-box',$url='/search',$save = false) {
));
}
function valid_email_regex($x){
if(preg_match('/^[_a-zA-Z0-9\-\+]+(\.[_a-zA-Z0-9\-\+]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/',$x))
return true;
return false;
}
function valid_email($x){
if(get_config('system','disable_email_validation'))
return true;
if(preg_match('/^[_a-zA-Z0-9\-\+]+(\.[_a-zA-Z0-9\-\+]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/',$x))
return true;
return false;
return valid_email_regex($x);
}
/**