Better regex for domain matching

This commit is contained in:
Ludovic Poujol 2019-03-19 19:11:58 +01:00
parent 3469dcfcd5
commit 501f6ebbab
1 changed files with 2 additions and 2 deletions

View File

@ -426,7 +426,7 @@ class DomainInputFormField extends FormField {
return FALSE;
}
if (!preg_match("/^[a-z0-9-.]+\.[a-z]{2,}$/i", $this->value)) {
if (!preg_match("/^[a-z0-9-.]+\.[a-z0-9-]{2,}$/i", $this->value)) {
if($set_error) $this->error = 'Ceci n\'est pas un nom de domaine';
return FALSE;
}
@ -476,7 +476,7 @@ class DomainListInputFormField extends FormField {
if(strlen($this->value)){
$list = explode(',', $this->value);
foreach ($list as $value) {
if (!preg_match("/^[a-z0-9-.]+\.[a-z]{2,}$/i", $value)) {
if (!preg_match("/^[a-z0-9-.]+\.[a-z0-9-]{2,}$/i", $value)) {
if($set_error) $this->error = 'Ceci n\'est pas un nom de domaine';
return FALSE;
}