mirror of
https://github.com/getnamingo/registry.git
synced 2025-05-17 01:57:00 +02:00
More bugfixes in CP and EPP
This commit is contained in:
parent
63b544c915
commit
c09f5b0e3c
3 changed files with 104 additions and 57 deletions
|
@ -685,4 +685,29 @@ function validateLocField($input, $minLength = 5, $maxLength = 255) {
|
|||
return mb_strlen($input) >= $minLength &&
|
||||
mb_strlen($input) <= $maxLength &&
|
||||
preg_match($locRegex, $input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a hostname or domain name.
|
||||
*
|
||||
* @param string $hostName
|
||||
* @return bool
|
||||
*/
|
||||
function validateHostName(string $hostName): bool
|
||||
{
|
||||
// Ensure length is under 254 characters
|
||||
if (strlen($hostName) >= 254) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Use filter_var to validate domain/hostnames
|
||||
if (!filter_var($hostName, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Optional: regex for stricter validation (if needed)
|
||||
return preg_match(
|
||||
'/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/',
|
||||
$hostName
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue