From e4354a0d7b821479a4d14c3bf0663cd38f8adff8 Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Fri, 9 Nov 2018 13:18:42 -0500 Subject: [PATCH] Update and Remove isValidEmail change function calls, and remove unneeded function. --- mod/dirfind.php | 2 +- mod/invite.php | 2 +- mod/settings.php | 2 +- src/Model/User.php | 2 +- src/Util/Strings.php | 12 ------------ 5 files changed, 4 insertions(+), 16 deletions(-) diff --git a/mod/dirfind.php b/mod/dirfind.php index b814d3b4f7..7ef217253e 100644 --- a/mod/dirfind.php +++ b/mod/dirfind.php @@ -53,7 +53,7 @@ function dirfind_content(App $a, $prefix = "") { if (strpos($search,'@') === 0) { $search = substr($search,1); $header = L10n::t('People Search - %s', $search); - if ((Strings::isValidEmail($search) && Network::isEmailDomainValid($search)) || + if ((filter_var($search, FILTER_VALIDATE_EMAIL) && Network::isEmailDomainValid($search)) || (substr(Strings::normaliseLink($search), 0, 7) == "http://")) { $user_data = Probe::uri($search); $discover_user = (in_array($user_data["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA])); diff --git a/mod/invite.php b/mod/invite.php index 5d33dd30aa..e0c73aa344 100644 --- a/mod/invite.php +++ b/mod/invite.php @@ -56,7 +56,7 @@ function invite_post(App $a) foreach ($recipients as $recipient) { $recipient = trim($recipient); - if (! Strings::isValidEmail($recipient)) { + if (!filter_var($recipient, FILTER_VALIDATE_EMAIL)) { notice(L10n::t('%s : Not a valid email address.', $recipient) . EOL); continue; } diff --git a/mod/settings.php b/mod/settings.php index 142555691f..e9dd023f9d 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -517,7 +517,7 @@ function settings_post(App $a) $email = $a->user['email']; } // check the email is valid - if (!Strings::isValidEmail($email)) { + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $err .= L10n::t('Invalid email.'); } // ensure new email is not the admin mail diff --git a/src/Model/User.php b/src/Model/User.php index 7447c02740..e03bf1c395 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -499,7 +499,7 @@ class User throw new Exception(L10n::t('Your email domain is not among those allowed on this site.')); } - if (!Strings::isValidEmail($email) || !Network::isEmailDomainValid($email)) { + if (!filter_var($email, FILTER_VALIDATE_EMAIL) || !Network::isEmailDomainValid($email)) { throw new Exception(L10n::t('Not a valid email address.')); } if (self::isNicknameBlocked($nickname)) { diff --git a/src/Util/Strings.php b/src/Util/Strings.php index 5636a5ca02..30f8b7329a 100644 --- a/src/Util/Strings.php +++ b/src/Util/Strings.php @@ -353,18 +353,6 @@ class Strings return $ret; } - /** - * @brief Check for a valid email string - * - * @param string $email_address Email address to be evaluated. - * - * @return boolean Value indicating whether or not the string is a valid email address. - */ - public static function isValidEmail($email_address) - { - return preg_match('/^[_a-zA-Z0-9\-\+]+(\.[_a-zA-Z0-9\-\+]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/', $email_address); - } - /** * @brief Normalize url * -- 2.39.5