From dfe05b9344580fd4c98a4b9db04ffd4819b900e1 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 5195fb77a3..c30935d9d5 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -1276,7 +1276,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 bb8f94c9a5..68144590af 100644 --- a/src/Module/Invite.php +++ b/src/Module/Invite.php @@ -63,7 +63,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 1d1a4a51ba..b14d8088ba 100644 --- a/static/defaults.config.php +++ b/static/defaults.config.php @@ -654,6 +654,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, ], 'performance' => [ // max_response_data_size (Integer) -- 2.39.5