From 95aa77647bee6303eb1abe2949ec0608d59d020e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 26 Sep 2022 10:20:56 +0200 Subject: [PATCH] Changes: - on local networks (LANs) you may not always have valid email addresses, e.g. mine here are structured as user@host.local which are not valid and won't pass validation check. - for these rare cases you can bypass the regex check but be warned to NEVER do this on a public server!!! --- src/Model/User.php | 2 +- src/Module/Invite.php | 2 +- static/defaults.config.php | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Model/User.php b/src/Model/User.php index f90d60c3cd..3463437103 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -1240,7 +1240,7 @@ class User throw new Exception(DI::l10n()->t('Your email domain is not among those allowed on this site.')); } - if (!filter_var($email, FILTER_VALIDATE_EMAIL) || !Network::isEmailDomainValid($email)) { + if (DI::config()->get('system', 'only_valid_email_addresses', true) && (!filter_var($email, FILTER_VALIDATE_EMAIL) || !Network::isEmailDomainValid($email))) { throw new Exception(DI::l10n()->t('Not a valid email address.')); } if (self::isNicknameBlocked($nickname)) { diff --git a/src/Module/Invite.php b/src/Module/Invite.php index 1f750f459f..f300f96435 100644 --- a/src/Module/Invite.php +++ b/src/Module/Invite.php @@ -78,7 +78,7 @@ class Invite extends BaseModule foreach ($recipients as $recipient) { $recipient = trim($recipient); - if (!filter_var($recipient, FILTER_VALIDATE_EMAIL)) { + if (DI::config()->get('system', 'only_valid_email_addresses', true) && !filter_var($recipient, FILTER_VALIDATE_EMAIL)) { DI::sysmsg()->addNotice(DI::l10n()->t('%s : Not a valid email address.', $recipient)); continue; } diff --git a/static/defaults.config.php b/static/defaults.config.php index 8519e117be..ef464c56d1 100644 --- a/static/defaults.config.php +++ b/static/defaults.config.php @@ -613,6 +613,13 @@ return [ // xrd_timeout (Integer) // Timeout in seconds for fetching the XRD links and other requests with an expected shorter timeout 'xrd_timeout' => 20, + + // only_valid_email_addresses (Boolean) + // WARNING: You normally want to only accept valid email addreses. Under + // rare conditions this however can be a hinderence, e.g. on your LAN + // where you might have email addresses like user@domain.local which are + // surely not valid but still you need to signup to your testing instance + 'only_valid_email_addresses' => true, ], 'proxy' => [ // forwarded_for_headers (String) -- 2.39.5