mirror of
https://github.com/getnamingo/registry.git
synced 2025-05-17 01:57:00 +02:00
parent
ef475600b3
commit
4fa1289334
6 changed files with 181 additions and 129 deletions
|
@ -666,4 +666,20 @@ function expandIPv6($ip) {
|
|||
}
|
||||
|
||||
return implode(':', $expanded);
|
||||
}
|
||||
|
||||
function validateLocField($input, $minLength = 5, $maxLength = 255) {
|
||||
// Normalize input to NFC form
|
||||
$input = normalizer_normalize($input, Normalizer::FORM_C);
|
||||
|
||||
// Remove control characters to prevent hidden injections
|
||||
$input = preg_replace('/[\p{C}]/u', '', $input);
|
||||
|
||||
// Define a general regex pattern to match Unicode letters, numbers, punctuation, and spaces
|
||||
$locRegex = '/^[\p{L}\p{N}\p{P}\p{Zs}\-\/&.,]+$/u';
|
||||
|
||||
// Check length constraints and regex pattern
|
||||
return mb_strlen($input) >= $minLength &&
|
||||
mb_strlen($input) <= $maxLength &&
|
||||
preg_match($locRegex, $input);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue