- corrected validation of Domain and URL (stupid php-bug)
This commit is contained in:
@@ -39,22 +39,13 @@ function validateDomain($domainname)
|
||||
|
||||
// there is a bug in php 5.2.13 - 5.3.2 which
|
||||
// lets filter_var fail if the domain has
|
||||
// a dash (-) in it. #
|
||||
if(version_compare("5.2.13", PHP_VERSION, "=")
|
||||
|| version_compare("5.3.2", PHP_VERSION, "="))
|
||||
{
|
||||
$pattern = '/^http:\/\/([a-z0-9]([a-z0-9\-]{0,61}[a-z0-9])?\.)+[a-z]{2,6}$/i';
|
||||
if(preg_match($pattern, $domainname_tmp))
|
||||
{
|
||||
return $domainname;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(filter_var($domainname_tmp, FILTER_VALIDATE_URL) !== false && filter_var($domainname_tmp, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED) === false && filter_var($domainname_tmp, FILTER_VALIDATE_URL, FILTER_FLAG_QUERY_REQUIRED) === false)
|
||||
{
|
||||
return $domainname;
|
||||
}
|
||||
// a dash (-) in it. As the PHP_VERSION constant
|
||||
// gives also patch-brandings, e.g. '5.3.2-pl0-gentoo'
|
||||
// we just always use our regex
|
||||
$pattern = '/^http:\/\/([a-z0-9]([a-z0-9\-]{0,61}[a-z0-9])?\.)+[a-z]{2,6}$/i';
|
||||
if(preg_match($pattern, $domainname_tmp))
|
||||
{
|
||||
return $domainname;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user