Don't allow wildcards in the domain part

This commit is contained in:
Lexi / Zoe 2026-07-30 19:40:27 +02:00
parent 7d78df604d
commit d812c03199
Signed by: binaryDiv
GPG key ID: F8D4956E224DA232

View file

@ -46,7 +46,7 @@ abstract class FormData
private static function validateMailAddress(string $address, bool $required = true, string $fieldName = 'Mail address'): ?string
{
// Note: This validator allows '%' as wildcard character inside mail addresses.
// Note: This validator allows '%' as wildcard character inside the username of mail addresses.
if (!$required && $address === '') {
return null;
}
@ -55,7 +55,7 @@ abstract class FormData
self::validateString($address, 3, 100, $fieldName)
);
if (!preg_match('/^[a-z0-9%._+-]+@[a-z0-9%.-]+$/', $address) || preg_match('/^\\.|\\.\\.|\\.@|@\\.|\\.$/', $address)) {
if (!preg_match('/^[a-z0-9%._+-]+@[a-z0-9.-]+$/', $address) || preg_match('/^\\.|\\.\\.|\\.@|@\\.|\\.$/', $address)) {
throw new InputValidationError("$fieldName is not valid (must be a valid mail address).");
}
return $address;